100 likes | 377 Views
Floating Point Binary. A2 Computing OCR Module 2509. Negative Binary Numbers. 4 10 = 00000100 3 10 = 00000011 2 10 = 00000010 1 10 = 00000001 0 10 = 00000000 -1 10 = ?. Imagine a milometer…. 0. 9. 0. 9. 9. 0. 9. 0. 0. 9. 0. 9. 9. 0. 4. 3. 2. 1. 0. 9.
E N D
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… 0 9 0 9 9 0 9 0 0 9 0 9 9 0 4 3 2 1 0 9
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 9 8 7 6 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 = 0 1 0 1 1 1 0 0 0 0 0 0 Flip Leave sign (0 ≡ positive; 1 ≡ negative) - 8810 = 1 0 1 0 Two’s complement
sign mantissa exponent 0 110100000 000011 Floating Point Binary Imagine a 2 byte, 16 bit, number… 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
sign mantissa exponent 0 110100000 111110 Floating Point Binary: Negative Exponent 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 If the leading bit of the exponent is 1, the exponent is negative… 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 lostsome accuracy and precision This number is normalised:it uses the mantissa to give the mostaccurate representation of the numberby making sure the first digit after thedecimal 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