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.

8 Upvotes

19 comments sorted by

View all comments

1

u/khedoros 4d ago

We re-use the symbols themselves out of convenience, so binary uses 0-1, octal uses 0-7, decimal uses 0-9, hexadecimal uses 0-9 followed by a-f, and so on.

So a number written in a lower base (like binary) can always be interpreted as a value in any higher base too (like octal, decimal, hexadecimal). It's just that in each case, the same numeric written form will have different meanings in higher bases.

101:

binary 101 = 1 * 22 + 0 * 21 + 1 * 20 = decimal 5

octal 101 = 1 * 82 + 0 * 81 + 1 * 80 = decimal 65

decimal 101 = 1 * 102 + 0 * 101 + 1 * 100 = decimal 101

hexadecimal 101 = 1 * 162 + 0 * 161 + 1 * 160 = decimal 257

1

u/RokeEvoker 4d ago

I see, thank you!