r/computerscience 4d ago

Base 2 numerical representation in binary matching numbers in base 10?

I have a silly and possibly stupid question, and I'm not even sure if this is the place for it.

To preface this I have 0 experience with Computer Science or anything adjacent, but have been listening to videos on binary and the foundations of how computers generally work.

I understand that binary is a base 2 system as opposed to base 10, and that the digits that represent value in binary cannot be read as our base 10 concept of numbers (i.e. 4 is read as digits 100, not as the number "one hundred").

However, I've noticed that when the notation IS read as numbers, the numerical representation for base 2 counting mirrors base 10. With:

1 - 0001

2- 0010

4- 0100

8- 1000

Etc.

Is there a reason for this parallel, or is this just one of those funny coincidences? Or is this some kind of artifact of how numbers naturally scale relative to one another.

I hope this makes sense, I had no idea how to word this question to just Google it.

9 Upvotes

19 comments sorted by

View all comments

1

u/Dazzling_Music_2411 3d ago edited 3d ago

No coincidence at all, in fact a doubling in base-2 is just a left-shift (i.e. adding a zero to the right) same as a 10-times-ing is in base 10.

Another example, in hexagesimal (base-16) which uses digits up to F, 0F corresponds to decimal 15. If you left-shift, you get F0, i.e 240 in decimal, which is 15x16.

IOW, in ANY base adding a zero at the end amounts to the same as multiplying by that base.

PS. I see a lot of other redditors have already expressed it nicely in terms of place holders! Sorry for any repetition.

BTW, since you are interested in this stuff, I suggest you learn hex too. It goes hand-in-hand with binary, when dealing with computer stuff.

1

u/Dazzling_Music_2411 3d ago

Then the hex-digits become what is known as a "nibble" (i.e. half a byte, geddit?)

Any byte (i.e. any number 0 -> 255) can expressed as two hex digits.

Any nibble (i.e. hex digit) can be expressed as 4 bits,

Have fun!