Bases |
This course does not teach the fundamentals of bases. Integer
Bases:
- 1 - Decimal-base10 (ex: int MyInt = 1;)
- 01 - Octal-base8 (leading zero) (ex: int MyInt = 01;)
- 0x1 - Hexadecimal-base16 (leading 0x) (ex: int MyInt = 0x1;)
- '\u0000' - Unicode base 16
- '\u000' - Unicode base 8
Example of: ? base = base 2 = base 10
- 10 base 10 = 1010 base 2 = 10 base 10
- 010 base 8 = 1000 base 2 = 8 base 10
- 0x10 base 16 = 0001 0000 base2 = 16 base 10
Legal statements:
- int test = 10;
//Base 10 to int
- int test = 010;
//Octal to int
- int test =0x10
//Hex to int
- double d = 0x12345678; //Hex to a double
Examples:
- int oi = 012; System.out.println(oi); // shows 10.
|