Published by Patrick Mutisya · 14 days ago
Computers operate using binary (base‑2) because electronic circuits have two stable states: off (0) and on (1). Humans, however, find decimal (base‑10) more intuitive. Octal (base‑8) and hexadecimal (base‑16) are convenient shorthand notations for binary data.
In any base‑\$b\$ system, the value of a digit \$di\$ at position \$i\$ (counting from right, starting at 0) is \$di \times b^{i}\$.
Example for binary number \$1011_2\$:
\$10112 = 1\times2^{3}+0\times2^{2}+1\times2^{1}+1\times2^{0}=8+0+2+1=11{10}\$
Group binary digits in sets of three, starting from the right. Replace each group with its octal equivalent.
Group binary digits in sets of four, starting from the right. Replace each group with its hexadecimal equivalent.
| Binary (4‑bit) | Octal | Decimal | Hexadecimal |
|---|---|---|---|
| 0000 | 0 | 0 | 0 |
| 0001 | 0 | 1 | 1 |
| 0010 | 0 | 2 | 2 |
| 0011 | 0 | 3 | 3 |
| 0100 | 0 | 4 | 4 |
| 0101 | 0 | 5 | 5 |
| 0110 | 0 | 6 | 6 |
| 0111 | 0 | 7 | 7 |
| 1000 | 1 | 8 | 8 |
| 1001 | 1 | 9 | 9 |
| 1010 | 1 | 10 | A |
| 1011 | 1 | 11 | B |
| 1100 | 1 | 12 | C |
| 1101 | 1 | 13 | D |
| 1110 | 1 | 14 | E |
| 1111 | 1 | 15 | F |
Two’s complement is the standard method for representing signed integers in binary.
Example: Represent \$-13_{10}\$ in an 8‑bit two’s complement system.
\$13{10}=000011012\$
\$\text{One's complement}=11110010_2\$
\$\text{Add 1}=11110011_2\$
Thus \$-13{10}=111100112\$.
IEEE 754 single‑precision format uses 32 bits:
The value is \$(-1)^{S}\times1.M\times2^{(E-127)}\$.