JAVA hexadecimal representation

Different computers use binary instructions:

For integer, there are four kinds of representation:

> Binary: 0, 1, 2 into a full, or start with a 0b in JAVA 0B

> Decimal: 0-9, into the full 10 1

> Octal: 0-7, 8 into a full, expressed in numbers begin with 0

> Hex: 0-9 grade AF, over 16 into the 1. He expressed with 0x or 0X. AF case insensitive here: As 0x21AF + 1 = 0X21B0

 

class BinaryTest{

     public static void main(String[] args){

           int num1 = 0b110;

           int num2 = 110;

           int num3 = 0127;

           int num4 = 0x110A;

 

           System.out.println("num1 = " + num1);

           System.out.println("num2 = " + num2);

           System.out.println("num3 = " + num3);

           System.out.println("num4 = " + num4);

     }

}

Published 144 original articles · won praise 44 · views 130 000 +

Guess you like

Origin blog.csdn.net/u013294097/article/details/102491833