Integers
Number representation in different radix/base
Decimal Representation - base 10
- Base 10 is an arbitrary choice, digit 0-9.
- We can use any base to represent numbers, like base 7.
Binary Representation - base 2
- Modern computing uses binary numbers, because digital devices can easily produce high or low level voltages which can represent 1 or 0.
- The base or radix is 2, digits 0 and 1.
Binary numbers hard for humans to read — too many digits! Conversion to decimal awkward and hides bit values. Solution: write numbers in hexadecimal!
Hexadecimal Representation - base 16
- The base or radix is 16 … digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
- Write number as $3AF1_{16}$ and interpret as:
3 × 16^3 + 10 × 16^2 + 15 × 16^1 + 1 × 16^0 == $15089_{10}$
- In C,
0x
prefix denotes hexadecimal, e.g. 0x3AF1
Octal Decimal Representation -base 8
- Octal (based 8) representation used to be popular for binary numbers, since its imilar advantages to hexadecimal