Floating Point Binary A2 Computing OCR Module 2509
Negative Binary Numbers 410 = 00000100 310 = 00000011 210 = 00000010 110 = 00000001 010 = 00000000 -110 = ? Imagine a milometer… 9 9 9 9 9 9 9 9 1 4 3 2
Negative Binary Numbers 410 = 00000100 310 = 00000011 210 = 00000010 110 = 00000001 010 = 00000000 -110 = 11111111 -210 = 11111110 -310 = 11111101 -410 = 11111100 Imagine a milometer… 9 9 9 9 9 9 9 6 8 7 9 Two’s complement
Negative Binary Numbers: The Easy Method Starting from the right, leave the digits alone up to the first 1 Change all the other digits from 1 to 0 or 0 to 1 8810 = 1 1 1 1 Flip Leave sign (0 ≡ positive; 1 ≡ negative) - 8810 = 1 1 Two’s complement
Floating Point Binary 110100000 000011 0.1101 x 23 ≡ 110.1 ≡ 6.510 Imagine a 2 byte, 16 bit, number… 110100000 000011 mantissa exponent sign The sign tells us it is a positive number (0 ≡ positive, 1 ≡ negative) The mantissa and exponent tell us that that the number is 0.1101 x 23 0.1101 x 23 ≡ 110.1 ≡ 6.510
Floating Point Binary: Negative Exponent If the leading bit of the exponent is 1, the exponent is negative… 110100000 111110 mantissa exponent sign N.B. If the exponent is negative, it will be written in two’s complement Therefore, first convert the exponent from two complement to base 10: 111110 = -000010 = -2 Number is therefore 0.1101 x 2-2 0.1101 x 2-2 ≡ 0.001101 ≡ 1/8+1/16+1/64 ≡ 0.203125
Normalisation of Floating Point Binary Numbers In base 10: 234,567,000 ≈ 0.002346 x 1011 234,567,000 = 0.234567 x 109 This has lost some accuracy and precision This number is normalised: it uses the mantissa to give the most accurate representation of the number by making sure the first digit after the decimal place is significant (i.e. not a zero)
Normalisation of Floating Point Binary Numbers Normalise the floating point binary number 0 000110101 000010 What do we know? It is a positive number It has a positive exponent The number, as it stands, is 0.000110101 x 22 = 0.0110101 Normalised: = 0.110101 x 2-1 We need the binary equivalent of -1 to represent the exponent N.B. The exponent is negative so will need to be two’s complement Two’s complement of -1 is 111111 So, the normalised version of 0 000110101 000010 is: 0.110101000 111111 The sign bit is a 0 The leftmost bit of the exponent is also 0