Converting Decimal to Binary to Decimal Representation Grouping
Converting Decimal to Binary to Decimal Representation
Grouping by 10 (Decimal) • The BASE 10—or decimal—number system is structured around groups of 10. • Imagine you were a wampum trader, and you had a lot of shells Wampum? ! feel so inferior. and beads. A LOT OF ITHEM. To keep track of how many, you decide to group them in 10 s. 2
10 s of wampum What a disorganized mess! Let’s group them! 32 groups of 10 4 leftover 3
100 s of wampum Wait! Why stop there? We can group our groups of ten into groups of ten! 3 groups of 10= 3 × 102 2 leftover groups of 10 = 2 × 101 4 leftover = 4 × 100 = 3 × 102 + 2 × 101 + 4 × 100 = 324 4
Instead of groups of 10… • Why use groups of 10? We can group by any number: grouping in pairs yields the BASE 2—or binary—number system. Make groups of 2, 1 left over 1× 20 Make groups of 2, 1 group of 2 left over 1× 21 ✗ Make groups of 2, 0 group of groups of 2 left over ✗ =1× 23 0× 22 Make groups of 2, 0 group of 2 groups of 2 left over +0× 22 +1× 21 +1× 1× 23 20 = 5
Converting Binary Decimal • Converting from binary to decimal is fairly simple because decimal digits hold more information thanbits. binary digits. • Consider the binary number 10111012. • This means the value 1× 26 + 0× 25 + 1× 24 + 1× 23 + 1× 22 + 0× 21 + = 1× 20 1× 64 + 0× 32 + 1× 16 + 1× 8 + 1× 4 + 0× 2 + = 1× 1 64 +16 + 8 + 4 + 1 = 93 6
Converting Decimal Binary • Converting decimal to binary is more tedious. • Consider the following algorithm (as used by The Amazing Binari): 1. If your number is odd, subtract 1 and write a corresponding ‘ 1’ down for your binary representation (moving RIGHT to LEFT). If you number is even, write down a ‘ 0’. 2. Divide by 2. 3. Repeat steps 1– 2 until you’ve reached 0. 7
- Slides: 7