what is a byte
A byte consists of 8 bits. Bits contain 0 or 1.
//byte example: 10010010
How do bytes represent a value?
It depends on the places where bits are turned on (have a value of 1)
For example, you want to represent number 1 (decimal) in binary
128 64 32 16 8 4 2 1 //Sum up this value if the bit is turned on
0 0 0 0 0 0 0 1
0 + 0 + 0 + 0 + 0 + 0 + 0 + 1 = 1
The one above represents number 1 in decimal.
What is 1 + 1 in binary??
0000 0001
0000 0001 +
--------------
0000 0010
What happend?
We just created 2 in binary! What an amazing world we live in.
128 64 32 16 8 4 2 1
0 0 0 0 0 0 1 0 //we turned on the second bit to create 2
0 + 0 + 0 + 0 + 0 + 0 + 2 + 0 = 2
Starting to make some sense?
Lets add 1 again (2 + 1 in decimal):
0000 0001
0000 0010 +
--------------
0000 0011
Convert to decimal:
128 64 32 16 8 4 2 1
0 0 0 0 0 0 1 1
2 + 1 = 3
//Happy coding