Fig 33.1 : Nitpicking or out of scope?


#1

Maybe I’m nitpicking but I didnt understand figure 33.1 in Chapter 33 / page 239 until I googled decimal representation.

I couldn’t see right away how the representation added to 60.

[color=#BFBFBF]128 64 32 16 8 4 2 1[/color]
| 0 | 0 | 1 | 1 | 1 | 1 | 0 | 0 |
[color=#BFBFBF] 32 16 8 4 = 60[/color]

but where did the 32, 16, 8, 4 come from?

seems like you have to figure in the 2^x for each number position. That is… 2^0, 2^1, 2^2, 2^3 etc. Or 2^0 to 2^7 (for 8bits or 1 byte)
and then
multiply each value by 1 or 0 in the binary representation.

So in the above example of binary value 0 0 1 1 1 1 0 0:
[color=#FF4000]0[/color] x 2^7 + [color=#FF4000]0[/color] x 2^6 + [color=#FF4000]1[/color] x 2^5 + [color=#FF4000]1[/color] x 2 ^4 + [color=#FF0000]1[/color] x 2^3 + [color=#FF0000]1[/color] x 2^2 + [color=#FF0000]0[/color] x 2^1 + [color=#FF0000]0[/color] x 2^0

which gives:
0 + 0 + 32 + 16 + 8 + 4 = 60

please let me know, if you see a flaw in this…

For those interested, tackle Fig 33.2 with a handy Decimal > Hex > Binary conversion table is here ascii.cl/conversion.htm


#2

Yes, you’re interpreting it correctly.

I’ve often wondered if Douglas Adams knew/appreciated the symmetry of the number 42 in binary: 101010


#3

Thanks!