Number Systems 1234 Decimal Notation 1011 (B) 1 + 1 * 2 + 0 * 4 + 1 * 8 = 11 (D) General Rule: last digit * 2^0 + second last digit * 2^1 + third last digit * 2^2 .... 1 2 4 8 16 32 64 128 256 10111 (B) = 23 (D) 25 (D) = ? (B) = 00011001 (B) 25 / 2 = 12 R 1 12 / 2 = 6 R 0 6 / 2 = 3 R 0 3 / 2 = 1 R 1 1 / 2 = 0 R 1 52 (D) = ? (B) = 00110100 (B) 52 / 2 = 26 R 0 26 / 2 = 13 R 0 13 / 2 = 6 R 1 6 / 2 = 3 R 0 3 / 2 = 1 R 1 1 / 2 = 0 R 1 8 bit = 1 byte char datatype: 256 different character, which are internally 0..255 short int datatype, 2 byte / 16 bits, -32.000..+32.000 int datatype, 4 bytes, 32 bits, -2.1 bio... + 2.1 bio Octal - base 8 123 (O) = 83 (D) 3 * 8^0 = 3 * 1 = 3 2 * 8^1 = 2 * 8 = 16 1 * 8^2 = 1 * 64 = 64 83 (D) = ? (O) 83 / 8 = 10 R 3 10 / 8 = 1 R 2 1 / 8 = 0 R 1 83 (D) = 1010011 (B) 83 / 2 = 41 R 1 41 / 2 = 20 R 1 20 / 2 = 10 R 0 10 / 2 = 5 R 0 5 / 2 = 2 R 1 2 / 2 = 1 R 0 1 / 2 = 0 R 1 1010011 (B) = ? (O) = 001 010 011 (B) 001 1 010 2 011 3 100 4 101 5 110 6 111 7 15263 (O) = ? B = 001 101 010 110 011 = 1101010110011 In C++: Any integer that start with a zero (0) is interpreted as an octal number! Hexadecimal - Base 16 10 A 11 B 12 C 13 D 14 E 15 F 82 (H) = 130 (D) 2 * 1 = 2 8 * 16 = 128 82 (D) = 52 H 82 / 16 = 5 R 2 5 / 16 = 0 R 5 130 (D) = 82 (H) 130 / 16 = 8 R 2 8 / 16 = 0 R 8 8D (H) = 141 (D) 13 * 1 = 13 8 * 16 = 128 175 (D) = AF (H) 175 / 16 = 10 R 15 F 10 / 16 = 0 R 10 A 123 (H) = ? B = 0001 0010 0011 (B) A (H) = ? B = 1010 (B) ABCDEF (H) = ? B 1010 1011 1100 1101 1110 1111 (B) the 0x prefix indicates that the number is given in hexadecimal notation example: 0x123 0xaf 0xF6 0xaF Stream manipulator hex, dec and oct can be used to print in different notations