Skip to content

Instantly share code, notes, and snippets.

@aka56kg
Forked from sadedv/IntegerToBinary.java
Created December 23, 2020 10:44
Show Gist options
  • Save aka56kg/c571bccbc3edcd6e7d38698b600ac568 to your computer and use it in GitHub Desktop.
Save aka56kg/c571bccbc3edcd6e7d38698b600ac568 to your computer and use it in GitHub Desktop.
Перевести число в различные системы счисления - Java (в шестнадцатиричную, бинарную (двоичную)) Integer to Binary, to Hex and to Octal
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