Il s'agit d'une méthode permettant d'effectuer une conversion de base en Java. Comme il n'utilise que la bibliothèque standard, vous pouvez la copier et la coller immédiatement.
Java
final String bin = "11111110";
final int dec = Integer.parseInt(bin, 2);
final String oct = Integer.toOctalString(dec);
System.out.println(oct);
production
376
Java
final String bin = "11111110";
final int dec = Integer.parseInt(bin, 2);
System.out.println(dec);
production
254
Java
final String bin = "11111110";
final int dec = Integer.parseInt(bin, 2);
final String hex = Integer.toHexString(dec);
System.out.println(hex);
production
fe
Java
final String bin = "11111110";
final int dec = Integer.parseInt(bin, 2);
final String base32 = Integer.toString(dec, 32);
System.out.println(base32);
production
7u
Java
final String bin = "11111110";
final int dec = Integer.parseInt(bin, 2);
final int n = 36;
final String base36 = Integer.toString(dec, n);
System.out.println(base36);
production
72
Java
final String oct = "376";
final int dec = Integer.parseInt(oct, 8);
final String bin = Integer.toBinaryString(dec);
System.out.println(bin);
production
11111110
Java
final String oct = "376";
final int dec = Integer.parseInt(oct, 8);
System.out.println(dec);
production
254
Java
final String oct = "376";
final int dec = Integer.parseInt(oct, 8);
final String hex = Integer.toHexString(dec);
System.out.println(hex);
production
fe
Java
final String oct = "376";
final int dec = Integer.parseInt(oct, 8);
final String base32 = Integer.toString(dec, 32);
System.out.println(base32);
production
7u
Java
final String oct = "376";
final int dec = Integer.parseInt(oct, 8);
final int n = 36;
final String base36 = Integer.toString(dec, n);
System.out.println(base36);
production
72
Java
final int dec = 254;
final String bin = Integer.toBinaryString(dec);
System.out.println(bin);
production
11111110
Java
final int dec = 254;
final String oct = Integer.toOctalString(dec);
System.out.println(oct);
production
376
Java
final int dec = 254;
final String hex = Integer.toHexString(dec);
System.out.println(hex);
production
fe
Java
final int dec = 254;
final String base32 = Integer.toString(dec, 32);
System.out.println(base32);
production
7u
Java
final int dec = 254;
final int n = 36;
final String base36 = Integer.toString(dec, n);
System.out.println(base36);
production
72
Java
final String hex = "fe";
final int dec = Integer.parseInt(hex, 16);
final String bin = Integer.toBinaryString(dec);
System.out.println(bin);
production
11111110
Java
final String hex = "fe";
final int dec = Integer.parseInt(hex, 16);
final String oct = Integer.toOctalString(dec);
System.out.println(oct);
production
376
Java
final String hex = "fe";
final int dec = Integer.parseInt(hex, 16);
System.out.println(dec);
production
254
Java
final String hex = "fe";
final int dec = Integer.parseInt(hex, 16);
final String base32 = Integer.toString(dec, 32);
System.out.println(base32);
production
7u
Java
final String hex = "fe";
final int dec = Integer.parseInt(hex, 16);
final int n = 36;
final String base36 = Integer.toString(dec, n);
System.out.println(base36);
production
72
Java
final String base32 = "7u";
final int dec = Integer.parseInt(base32, 32);
final String bin = Integer.toBinaryString(dec);
System.out.println(bin);
production
11111110
Java
final String base32 = "7u";
final int dec = Integer.parseInt(base32, 32);
final String oct = Integer.toOctalString(dec);
System.out.println(oct);
production
376
Java
final String base32 = "7u";
final int dec = Integer.parseInt(base32, 32);
System.out.println(dec);
production
254
Java
final String base32 = "7u";
final int dec = Integer.parseInt(base32, 32);
final String hex = Integer.toHexString(dec);
System.out.println(hex);
production
fe
Java
final String base32 = "7u";
final int dec = Integer.parseInt(base32, 32);
final int n = 36;
final String base36 = Integer.toString(dec, n);
System.out.println(base36);
production
72
Java
final String base36 = "72";
final int n = 36;
final int dec = Integer.parseInt(base36, n);
final String bin = Integer.toBinaryString(dec);
System.out.println(bin);
production
11111110
Java
final String base36 = "72";
final int n = 36;
final int dec = Integer.parseInt(base36, n);
final String oct = Integer.toOctalString(dec);
System.out.println(oct);
production
376
Java
final String base36 = "72";
final int n = 36;
final int dec = Integer.parseInt(base36, n);
System.out.println(dec);
production
254
Java
final String base36 = "72";
final int n = 36;
final int dec = Integer.parseInt(base36, n);
final String hex = Integer.toHexString(dec);
System.out.println(hex);
production
fe
Java
final String base36 = "72";
final int n = 36;
final int dec = Integer.parseInt(base36, n);
final String base32 = Integer.toString(dec, 32);
System.out.println(base32);
production
7u
Java
final String base36 = "72";
final int n = 36;
final int dec = Integer.parseInt(base36, n);
final int m = 3;
final String base3 = Integer.toString(dec, m);
System.out.println(base3);
production
100102
Recommended Posts