|
|
||
| You are here: | ||
|
4.1.3 The number part is usually normalized , ie made to fit within a certain range (in the above examples, the first digit after the decimal point has to be 1 through 9).
More bits would be allocated in a real computer system.
Which is the topic of the next page . |
On this page: [ mantissa & exponent | range of numbers | compared to integers ] First some terminology: given 0.32855932 x 10 4 . The number (ie 0.32855932) is called the mantissa and the power (ie 4) is called the exponent . To represent binary floating-point numbers we will use a binary (fractional) mantissa and an integer exponent which both use two's complement representation in 16-bits. A possible compromise between a large mantissa (greater accuracy) and a large exponent (greater range) could be to allocate 10 bits for the mantissa and 6 for the exponent: <--------------------------------- mantissa -----------------------------><------------exponent -------->
^
What is this in decimal? Well, do it in two parts, first the mantissa stays as it is; the value of the exponent is +4. Therefore the binary point must be moved four places to the right in the mantissa: 0.110101000 becomes 1101.01000 that is 13.25 in decimal. Now for a negative mantissa and exponent:
Stage 1 - complement the mantissa: 1.101101000 becomes 0.0 1 0 0 1 1 0 0 0, that is - 0.010011000 in "ordinary" binary. Stage 2 - shift the mantissa, the exponent is -6, so move the binary point 6 places to the left: - 0.010011000 becomes - 0.000000010011000 or something quite small 1/256 + 1/2048 + 1/4096 = (16+2+1)/4096 = 0.00415039 -ish. Convert the following to decimal equivalents:
In the second and third representations above, there are leading zeros following the binary point and therefore less space to store any low value bits. Notice that the first number 2 1/128 could not be stored with the higher exponents, the LSB of the mantissa would be lost. In order to preserve the maximum possible accuracy , the numbers are normalised (as for the decimal floating point number example given at the start of this section). Because we are using two's complement binary fractions , normalising positive and negative numbers is different. Positive is not so bad: the MSB (excluding the sign bit) must be a 1 (ie no trailing zeros after the point). Thus 0.000111100 would be expressed as 0.111100000 With a corresponding shift in the exponent: 0.000111100 000000 then becomes 0.111100000 111101 an exponent of -3. For negative numbers there must be no leading 1's to the left of the point, the MSB must be a zero (which is the significant bit in two's complement): 1111100100 would be expressed as 1.001000000 (Why? Leading 1's in a two's complement negative number may be ignored in just the same way that leading zeros may be ignored in a positive number). This requires a shift of 5 places as shown below: 1111100100 000000 then becomes 1.001000000 000101 To confirm this, complement the mantissa and then shift it 5 places to the right. Quick Quiz: Which of the following decimal numbers link with which normalised binary numbers:
Question : What happens if you allocate 5 bits to the mantissa and 8 bits to the exponent? Range of Normalised Floating Point Binary Numbers Consider a representation using only 10 bits, 6 for the mantissa and 4 for the exponent: the principal is the same but the numbers are easier to handle mentally.
What is the largest positive number that can be represented? The largest positive number will require the largest positive mantissa and the largest positive exponent. What is the smallest positive number that can be represented? What is the largest negative number that can be represented? What is the smallest negative number that can be represented? (answers 124, 0.001953125, -128, -0.002075195313-ish) Integer and Floating Point Representations Compared Complete accuracy of storage (as long as there are enough bits allocated). A larger range of numbers can be stored. related: [ Topic 4 home | previous: fixed point binary | next: errors ] |
|
|
|
|||
|
Questions or problems related to this web site should be addressed to Richard Jones who asserts his right to be identified as the author and owner of these materials - unless otherwise indicated. Please feel free to use the material presented here and to create links to it for non-commercial purposes; an acknowledgement of the source is required by the Creative Commons licence. Use of materials from this site is conditional upon your having read the additional terms of use on the about page and the Creative Commons Licence. View privacy policy. This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License. © 2001 - 2009 Richard Jones, PO BOX 246, Cambridge, New Zealand; This page was last modified: May 31, 2009 |