# Why are bits counted "1, 2, 4, 8" instead of "1, 2, 3, 4"?

#1

I'm not really stuck, I just don't understend one thing. I've copied the code from the example in the task.
And it says that result one's are number 2 and 8.

I can understand the logic for counting from right to left, but why it's not 2 and 4? I mean the physical place on let's say hard drive can have value either 1 or 0 and this counts as one place, then second, third and so on. Right?
Could someone please explain me the logic of counting this? I understand how to count in bitwise system but don't understand how to count digits in bitwise system.

``````     a:   00101010   42
b:   00001111   15
===================
a & b:   00001010   10``````

#2

It's the same thing as that "our" digits represent 1s, 10s, 100s, 1000s and so on, with the difference that we use base 10

#3

So people who were creating binary system just simply agreed that they will say "My file has size of 16 bits", but actually physycally it's 5 bits (meaning 5 digits). Just because they like to be like that. Right? ))) Like in base ten system to count digits we count every digit as 1 and sum it in base ten and in base 2 system for counting every digit you just multiply number by 2. Did I understand that one correctly?

I just got it:
the number is the number in decimal system starting from which the value can be assighned to the binary number with this amount of digits. I mean if you have number in base 2 that has 10 digits - it means that in base 2 number 1000 000 000 is 2^9

bin(1000000000) == (2**(len(1000000000) - 1)) # is True

Is that correct?

#4

That's something else and has to do with needing fixed size values for hardware reasons and being able to compute where something exists in memory

#5

What do you mean by "zero-pad"?
P.S. I've edited previous comment. Is that correct?

Do 1 and 0 in one bit physically take 1 place or two? I mean it's the same place changed between 0 and 1 or it's like they both are nearby, but one of them is "activated" or something like that?

#6

you can write 37 as 00000037 to give it a fix number of digits.

A transistor can be in two states, one state represents 0 and the other represents 1. If you have 32 transistors then they can represent a 32-bit integer. By copying those states around and doing operations on them we get things like addition.

Theoretically more than two states could be used but then it gets more difficult to tell which state they're in and is less reliable / not enough benefit / cost / whatever, don't know it all. Stuff.

#7

As for your math above, do the same thing with base 10 and see if your logic checks out. Then simply switch out 10s to 2s, it's the same system with a different base

#8

Ye, I've checked it with a billion.
Thanks.