Large Numbers
With base10, you can add as many columns as you like, and just increase the numbers size.
However with a computer you cant do that.
A computer needs a standard number of columns to represent a number - it uses 1byte (8bits, or 8columns) to represent a number.
If it didnt then it would get very confused, it wont know where one number starts and one number ends in the flow of electricity!
So, it allows 8 bits to represent a number, if a number is too large for a single byte, then it takes up 2 or more bytes!
Note, when the second byte starts, the power does not start again at 0, it continues from the end of the last byte!!!
Problem!
When a computer sends data from one pc to another it uses something called a 'protocol', this sets up a communication between the computers agreeing on the type of communication and things.
Now, not every binary number is stored in 8 bits as you will see when we look at bcd.
How does the computer know whether its a normal 8bit byte or bcd, how does it know when more than one byte is being used, how does it send fractions and negative numbers, and how does it send letters????????
Actually i dont know, if i find out ill put it here!
Note - everything a computer does is using binary, the binary code 01000001 means 65, but it also means the capital letter A !!!
Negative Numbers
The minimum value that can be stored in a single 8bit byte is 0, and the maximum (a 1 in every column) is 255.
We can increase the maximum by using multiple bytes, but what about negative numbers?
Negative numbers can be represented in two ways - Sign and Magnitude or Two's Complement.
Sign and Magnitude
The last bit (128's column) is now used to represent the sign, a 1 means negative, and a 0 means positive.
The range a single byte now has is -127 to +127.
If multiple bytes are being used only the very last bit is used for this purpose, not the last in each byte.
Twos Compliment
Here the last column instead of being 128, is replaced with -128 !!!
This makes things a little more complex but it makes arithmatic much easer later.
The range is -128 to +127.
Again, if multiple bytes are being used, only the very last bit is used for this purpose, not the last in each byte.
Fractions
How do you represent fractions?
In order to understand this you must understand twos compliment from above.
Okay, we have the fraction 23.45678
This can also be written as 0.2345678 x 102
We then store two parts, the number and the power.
The number 0.2345678 is called the 'mantissa' and the power 2 is called the 'exponent'.
To store the binary number 10111 as a fraction:
Change to 0.10111 x25 (exponent base10), then to 0.10111 x2101 (exponent base2).
You would then store the mantissa and exponent as 10111101 (in this case using 5 bits for the mantissa and 3 for the exponent).
However thats not quite right, you need to store both the mantissa and exponent in twos complement.
The first bit in both the mantissa and the exponent is a negative column, so for 10111 and 101 they would become 010111 and 0101.
And therefore it would become 0101110101 using 6 bits for the mantissa and 4 for the exponent.
If we wanted to store something like this: 0.00010101, we store 0.10101 as the mantissa and 1101 (base2 twos complement, -3 in base10) as the exponent.
We truncated the excess 0's at the beginning of the mantissa because it takes up less space to store the number of 0's youve removed, in the exponent, rather than storing the 0's themselves in the mantissa.
This also leaves more bits in the mantissa for actual data.
Doing this is called 'normalising', its done it order to store numbers as acurately as possible.
Increasing the length of the mantissa increases the accuracy of the stored number, increasing the length of the exponent increases the size of the stored number!