/**
* {@link <a href=
* "https://[Log in to view URL]"
* target="_blank">conversione da base decimale a esadecimale, ottale, e
* binaria</a>}
*
* @author itammb ( Italia Massimiliano Buscati )
* @version JDK 1.15
*
*/
class Main {
public static void baseConverion() {
// '0x' prefisso esadecimale
// numeri e lettere -> [0..9] e [a..f] (non case-sensitive)
int integer = 0xf;
System.out.println(integer + " -> " + Integer.toHexString(integer));
// '0' prefisso ottale
// numeri -> [0..7]
integer = 010;
System.out.println(integer + " -> " + Integer.toOctalString(integer));
// '0b' prefisso binario
// numeri -> [0..1]
integer = 0b10;
System.out.println(integer + " -> " + Integer.toBinaryString(integer));
}
public static void main(String[] args) {
// Unit test - conversione da base decimale a esadecimale, ottale, e binaria
baseConverion();
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: