int iBase10 = 1; String iBase2 = ""; System.out.println("Representation binaire des valeurs 1 >>>> 8:"); for(iBase10 = 1; iBase10<9; iBase10++) { iBase2 = Integer.toBinaryString(iBase10); iBase2 = (iBase2.length()>3?"":"0") + (iBase2.length()>2?"":"0") + (iBase2.length()>1?"":"0") + iBase2; System.out.println(iBase10 + " : " + iBase2); }
// Parse and format to binary bi = new BigInteger("1111111111", 2); // 1023 String s = bi.toString(2); // 1111111111
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questioniBase2 = (iBase2.length()>3?"":"0") + (iBase2.length()>2?"":"0") + (iBase2.length()>1?"":"0") + iBase2;
int nombreDeJours = 5; // avec 5 on affichera 5 jours, avec 1, 1 jour String jours = "jour" + (nombreDeJours>1?"s":""); System.out.println("dans " + nombreDeJours + " " + jours);