# Binary, base 2, bits, and coin flips

1. Dec 9, 2015

### RabbitWho

I am studying psychology and have always been awful at maths (I think it's because I don't have much working memory), I am coming at this as a complete beginner. It is relevant to the Information Processing model of psychology.
_____

The book says: Imagine you throw a coin once.. once it lands you have 1 bit of information. There are two (2) possible results
[log2(2)] = 1 bit

If you throw a coin twice you have two bits of info, there are four possible results (xx,++,+x,x+) (I don't know why they mention the possible results, is that relevant?)
[log2(4)] = 2 bits

Am I right in thinking the 4 in that equation corresponds to the four possible results?

The examples in the book end there, and I have been trying to expand it to check that I understand.

[log2(8)] = how many bits? I guess that question means "How many binary digits do you need to represent 8?" There are 256 possible results.. is that relevant?

[log2(8)] =3 bits if we were talking about coin tosses, and 4 bits on a computer because for some reason they always add one. Am I right?

In a computer
zero= 0
one = 1
two = 10
three = 11
four = 100

Why isn't 01 four?
Here I will guess

five = 101
six = 110
seven =111
eight = 1000

log base 2 of 8 is 3 so why do I need 8 digits to represent 8? Why can't I use 011?

A friend suggested that the computer would see 01 as being the same as 10. I am imagining a cent and a euro, they aren't the same coin so a tails with one is not the same as a tails with the other, they aren't interchangeable.. but I would have thought the same went for computer transistors? That is what 1 and 0 represent for computers, right? on and off switches?

_____

Thanks for any help you can give. I have googled it, but all the tutorials I find impart all the information relevant for IT then very quickly go into more advanced things like bytes etc. and don't deal in detail with the basic concept.

2. Dec 9, 2015

### .Scott

Yes.
You need 3 bits to represent one of eight possibilities.
If you are talking about how many states can be coded, it would be 3 on a computer as well. If you are talking about encoding the number 8, then there is an extra bit - because the lowest number encoded by a bit string is usually zero. So you are counting from 0 to 8, nine different value - so you you ned more than 3 bits.
You're not showing both bits.
In a computer
zero= 000
one = 001
two = 010
three = 011
four = 100

So 01 would be 001 - the code for one.
Same as above - this time with four bits.
In a computer
five = 0101
six = 0110
seven =0111
eight = 1000

So 011 would be 0011 - the code for three.
There are codes where a different number of bits (coin tosses) are use for different numbers. But in normal computer coding, there are fixed fields of bits - with a preset size. So if your number is eight and you are using 32-bit arithmetic, then you will see 00000000000000000000000000001000.

3. Dec 9, 2015

### RabbitWho

Thank you so much for your help. I think I understand.. So, for example

[log2(32)] = 5 bits?

4. Dec 9, 2015

### .Scott

Yup!!

5. Dec 11, 2015

### Staff: Mentor

log2(32) = 5, which is a number -- units should not be included.
Using 5 bits you can represent 32 numbers: 0, 1, 2, 3, ..., 31
The binary bit pattern for 31 (ie, in base-2) is 11111, which means $1 \text{ x } 2^4 + 1 \text{ x } 2^3 + 1 \text{ x } 2^2 + 1 \text{ x } 2^1 + 1 \text{ x } 2^0 = 16 + 8 + 4 + 2 + 1 = 31$

6. Dec 12, 2015

### Svein

Going the other way: A simple microcontroller handles information in 8 bit chunks (such a chunk is called a byte). What is the largest value you can represent in a byte?

7. Dec 12, 2015

### meBigGuy

In decimal the positions are weighted as powers of 10. In binary the positions are weighted as powers of 2

In decimal 10 symbols (0-9). The positions are (from right to left) 10^0, 10^1, 10^2 or 1, 10, 100
In binary 2 symbols (0-1). The positions are (from right to left) 2^0, 2^1, 2^2 or 1, 2, 4

Totally analagous