Skip to content

Instantly share code, notes, and snippets.

@sadedv
Last active February 14, 2024 19:09
Show Gist options
  • Save sadedv/ee4b5835c0ae609f68e0 to your computer and use it in GitHub Desktop.
Save sadedv/ee4b5835c0ae609f68e0 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);
}
}
@aka56kg
Copy link

aka56kg commented Dec 23, 2020

спасибо, помогло

@shvetsovart
Copy link

спасибо)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment