Login

Back 

Negative floating point numbers using two bytes

Negative binary floating-point number representation using two bytes
Two bytes will allow us to represent numbers with a greater range and accuracy than one byte. The more bits you can use for the mantissa, the greater the accuracy of the number. The more bits you can use for the exponent, the greater the range of numbers you can represent. When you have a fixed number of bits to use (e.g. one byte or two bytes) you have to balance how much accuracy you need with what range of numbers you want to represent.

Example 20. Convert 1001 1001 0000 0110 (10 bits for the mantissa and 6 for the exponent) into decimal.

    1. The mantissa is negative because the left most bit is a 'one'. Therefore the mantissa is in two's complement form!
    2. Write down the mantissa, 1.001100100. This is a two's complement number. It will need to be changed back into the binary system we are used to dealing with.
    3. Convert the two's complement number: 1.001100100 into a negative binary number that is not in 2s complement form. 1.001100100 becomes -(0.110011100) If you are having trouble with this step, refer back to the ‘Getting back to a negative denary number’ section. You simply start at the right most bit, copy all the bits up to and including the first ‘1’, and then invert the remaining bits. It doesn’t make any difference that there is a decimal point there!
    4. The exponent is 000110 This is +6 in decimal. We must move the decimal place 6 places to the right.
    5. -(0.110011100) now becomes -(0110011.100) Dropping redundant zeros, we get -(110011.1)
    6. Converting this to denary gives -(32+16+0+0+2+1+0.5) = -51.5

Example 21. Convert 1000 1100 0011 1100 (10 bits for the mantissa and 6 for the exponent) into decimal.

    1. The mantissa is a normalised negative number because the first bits of the mantissa are 10
    2. Write down the mantissa and convert from a 2s complement number into a negative pure binary number. 1.000110000 becomes -(0.111010000)
    3. The exponent is 111100. This is always in two's complement form and is negative because the left most digit is a one. Converting it, 111100 becomes -(000100), which is -4.
    4. Moving the decimal place in the mantissa 4 places left, -(0.111010000) becomes -(0.0000111010000)
    5. Removing unnecessary zeros gives us -(0.000011101)
    6. Converting, this gives -(1/32 + 1/64 + 1/128 + 1/512) The final answer is therefore -0.056640625

z17

z18

Converting negative denary numbers into normalised binary floating-point numbers is simply a reverse of what we have just been doing. The following two-byte examples use 10 bits for the mantissa and 6 bits for the exponent.

Example 22. Convert -20.5 into a normalised two-byte binary floating-point number

    1. This is a negative number. Convert -20.5 into a fixed-point number in two's complement form.
    2. Now +20.5 is 10100.1
    3. Pack the front of this number with excess zeros to make the mantissa the correct size. You now get 000010100.1
    4. The two's complement form of this is 111101011.1
    5. The normalised form of 111101011.1* is 1.010111000. *Notice that the excess 'ones' are discarded from the front of the number in negative numbers, just like excess 'zeros' are discarded in positive numbers. Excess zeros are then added to the end of the number to make the mantissa the correct size.
    6. To get the decimal place of the normalised form back to its original place, the decimal point needs to be moved 5 places to the right. The exponent therefore is 000101
    7. Putting all this together gives 1010 1110 0000 0101

Example 23. Convert -10.75 into a normalised two-byte floating-point number

    1. This is a negative number. Convert -10.75 into a fixed-point number in two's complement form.
    2. Now +10.75 is 1010.11
    3. Pack the front of this number with excess zeros to make the mantissa the correct size. You now get 00001010.11
    4. The two's complement form of this is 11110101.01
    5. The normalised form of 11110101.01* is 1.010101000 *Notice that the excess 'ones' are discarded from the front of the number in negative numbers, just like excess 'zeros' are discarded in positive numbers. Excess zeros are then added to the end of the number to make the mantissa the correct size.
    6. To get the decimal place of the normalised form back to its original place, the decimal point needs to be moved 4 places to the right. The exponent therefore is 000100
    7. Putting all this together gives 1010 1010 0000 0100

*Normalisation - a further note on discarding excess 1s
This is quite a difficult idea to understand. If you have any negative number that you need to put in the normalised form, start with the left-most bit and look for the first time that 10 occurs! That is where your decimal point should go. You then throw away all of the excess one bits to the left of that first ‘10’ pair, and add any zeros to the right hand side of the number to make up the correct size of the mantissa. Study example 24.

Example 24. Normalise 1110001.01

    1. Starting on the left, find the first time the 10 pair occurs and put the decimal point between the one and the zero. You bit pattern now looks like this: 111.000101 (Do remember how many places you had to move the decimal point – in this case, 4 places to the left. So to get new normalised number back to the original un-normalised number, the exponent will have to have the effect of moving the decimal point 4 places to the right).
    2. Now discard the unnecessary ones on the left of the 1.0 pair. Your bit pattern now looks like this: 1.000101
    3. Now add some extra zeros on the end of the number, to make up a mantissa of 10 places long. The bit pattern should now look like this: 1.000101000
    4. You have normalised the mantissa! Now you need to work out what the exponent should be and then put the mantissa and exponent together for the final answer.
    5. The exponent needs to be +4 or 000100
    6. The final answer is therefore 1000 1010 0000 0100

z19

You can check your answers to Tasks 26 and 27 by trying to reconvert your answer using the techniques you learnt in the examples 20 and 21.

Back