-
-
Save Sekator778/c140ea7c3d546dc1dd9eca3f561bdb59 to your computer and use it in GitHub Desktop.
Перевести число в различные системы счисления - Java (в шестнадцатиричную, бинарную (двоичную)) Integer to Binary, to Hex and to Octal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Main { | |
public static void main(String[] args) { | |
Integer number = 255; | |
// Бинарный формат числа | |
String convert = Integer.toBinaryString(number); | |
System.out.println(convert); | |
// Восьмиричная форма | |
convert = Integer.toOctalString(number); | |
System.out.println(convert); | |
// Шеснадцатиричная форма | |
convert = Integer.toHexString(number).toUpperCase(); | |
System.out.println(convert); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment