EEE120 - Module 2: Binary, Decimal, Octal, Hexadecimal
Convert between Binary, Decimal, Octal, and Hexadecimal instantly!
Uses: 0, 1
Example: 1011โ = 11โโ
Uses: 0-9
Example: 29โโ
Uses: 0-7
Example: 35โ = 29โโ
Uses: 0-9, A-F
Example: 1Dโโ = 29โโ
A number system is a way to represent numbers using a specific set of symbols (digits). Different systems use different bases.
MOD-10 system
Digits: 0 through 9
Most common for everyday use
MOD-2 system
Digits: 0 and 1
Foundation of digital electronics
MOD-8 system
Digits: 0 through 7
Groups 3 binary digits
MOD-16 system
Digits: 0-9, A-F
Groups 4 binary digits
Multiply each bit by 2 raised to its position power, then sum.
Divide by 2 repeatedly, recording remainders bottom-to-top.
Group binary digits in sets of 3 (from right), convert each group.
Group binary digits in sets of 4 (from right), convert each group.
Two's complement is the most common method for representing signed numbers in binary.
| 4-bit Binary | Unsigned | Signed (Two's Complement) |
|---|---|---|
| 0000 | 0 | 0 |
| 0001 | 1 | +1 |
| 0010 | 2 | +2 |
| 0011 | 3 | +3 |
| 0111 | 7 | +7 |
| 1000 | 8 | -8 |
| 1001 | 9 | -7 |
| 1111 | 15 | -1 |
For n bits: 0 to 2โฟ-1
4-bit: 0 to 15
Leading bit can be 0 or 1
For n bits: -2โฟโปยน to 2โฟโปยน-1
4-bit: -8 to +7
MSB (sign bit): 0=positive, 1=negative
Overflow occurs when the result exceeds the representable range. In signed arithmetic, overflow happens when CMSB โ Cout
A half adder adds two single bits and produces a sum and carry output.
| A | B | Sum | Carry |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 1 |
A full adder adds three bits: two inputs plus a carry-in, producing sum and carry-out.
| A | B | Cin | Sum | Cout |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 1 | 0 |
| 0 | 1 | 0 | 1 | 0 |
| 0 | 1 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 | 0 |
| 1 | 0 | 1 | 0 | 1 |
| 1 | 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 1 | 1 |
Multiple full adders chained together, with carry output of one feeding carry input of next.
Adding 1011โ + 0110โ
Convert 110110โ to decimal.
Convert 77โโ to binary.
Add 1101โ + 1011โ
Find the two's complement of 01010โ
Convert 2A9โโ to decimal.