280 likes | 620 Views
Number Systems. Computing Theory – F453. Data Representation. Data in a computer needs to be represented in a format the computer understands. This does not necessarily mean that this format is easy for us to understand. Not easy, but not impossible!
E N D
Number Systems Computing Theory – F453
Data Representation • Data in a computer needs to be represented in a format the computer understands. • This does not necessarily mean that this format is easy for us to understand. • Not easy, but not impossible! • A computer only understand the concept of ON and OFF. • Why? • How do we translate this into something WE understand? • We use a numeric representation (1s and 0s)
Data Representation • If a computer can only understand ON and OFF, which is represented by 1 and 0, then which is which? • 1 = ON • 0 = OFF • This is known as the Binary system. • Because there are only 2 digits involved, it is known as Base 2. • But what does it MEAN??!
Denary Numbers • We use the Denary Number System. • This is in Base 10, because there are 10 single digits in our number system. • Why? We are surrounded by things that are divisible by ten. • Counting in tens is not a new phenomenon… • Even the Egyptians did it!
Real Numbers • In the real world we have to work with decimal numbers, but there is no place in binary for a decimal point. In these cases, we need to ‘normalise’ the number. • In short, we place everything to the right of the decimal point: Positive exponent represents the decimal point moving left 10111.0 0.10111 x 25 0.10111 x 2101 010111101 Exponent Mantissa
Real Numbers • Example two: • The binary number 10.11011 with 8 bits for the mantissa and 6 for the exponent .1011011 0. .1011011 x 22 0.10111 x 210 01011011000010 Positive exponent represents the decimal point moving left Exponent Mantissa
Real Numbers • Example two: • The denary number 37.5 with 8 bits for the mantissa and 6 for the exponent 37.5 = 100101.1 0.1001011 x 26 0.1001011 x 2110 01001011000110 Positive exponent represents the decimal point moving left Exponent Mantissa
Real Numbers – Your Turn • Example three: • The denary number 52.75 with 8 bits for the mantissa and 8 for the exponent 52.75 = 110100.11 0.11010011 x 26 0.11010011 x 2110 01101001100000110 Positive exponent represents the decimal point moving left Exponent Mantissa
Real Numbers – Your Turn • Example four: • The denary number 22.8125 with 10 bits for the mantissa and 5 for the exponent 22.8125 = 010110.1101 0.101101101 x 25 0.101101101 x 2101 010110110101101 Positive exponent represents the decimal point moving left Exponent Mantissa
Real Numbers – In reverse • Example: • The binary number 01011100000011 with 8 bits for the mantissa and 6 for the exponent Mantissa Exponent 01011100000011 0.1011100 x 211 0.1011100 x 23 0101.1100 = 5.75
Real Small Numbers • In the real world we also have to work with numbers which are less than 1, or decimals. • This is tackled in the same way, but we make use of two’s complement for the exponent: Negative exponent represents the decimal point moving right 0.00010101 0.10101 x 2-3 0.10101 x 2-11 0.10101 x 2-11 01010111110101 Mantissa Exponent
Real Numbers – Your Turn • Example five: • The binary number 0.00110 with 8 bits for the mantissa and 8 for the exponent 0.00110 0.110 x 2-2 0.110 x 2-10 0.110 x 211111110 0000011011111110 Exponent Mantissa
Real Numbers – In reverse • Example: • The binary number 01011110111010 with 8 bits for the mantissa and 6 for the exponent Mantissa Exponent 01011110111010 0.1011110 x 2-110 0.1011110 x 2-6 0.0000001011110
Normalisation • In the examples, the point in the mantissa is always placed before the first zero (eg. 0.11010). • This not only allows for the maximum number to be held, but by ensuring that the first two digits are different, the mantissa is said to be normalised. • Therefore, for a positive number, the first digit is always a zero, and the exponent is held in two’s complement form.