# How to add two numbers in IEE754 half precision format?

i'm trying to understand how to add two numbers in IEE754 half precision format , i haven't found a good reference/tutorial on this , so i've tried to follow the 32 bit floating point addition procedure , but at some point i'm stucked , what i know is:

Half precision (16 bit) IEEE 754 floating point number bit configuration is:

1 bit for sign 5 bit for exponent bit and 10 bit for mantissa.

i have two numbers:

1110001000000001 0000001100001111

so i rewrited them as

1 11000 1000000001 0 00000 1100001111

before adding them i have to convert them in normalized binary scientific notation (i don't know if i'm right):

Convert the exponent of the first number in decimal: 24 Subtract bias (that is 15) so i have: 24-15 = 9 so the exponent is 9

so the mantissa is : 1.000000001 * 2^9

But i don't know how to continue , can someone please explain me the correct process for solving this , or link me a good reference/title of a book for understanding this procedure? i'm searching on Google and trying to understand on different books , but i can't clarify this procedure to myself.

• How would you proceed for 32 bit numbers and why doesn't it work for 16 bit numbers? Sep 19, 2016 at 13:42

The second number has zero as exponent and has non zero mantissa, so it is a Denormal (aka Subnormals)

0 01111 1100001111 = 1.1100001111 * 2**0   = 1.1100001111
0 01110 1100001111 = 1.1100001111 * 2**-1  = 0.11100001111
0 01101 1100001111 = 1.1100001111 * 2**-2  = 0.011100001111
0 01100 1100001111 = 1.1100001111 * 2**-3  = 0.0011100001111
0 01011 1100001111 = 1.1100001111 * 2**-4  = 0.00011100001111
0 01010 1100001111 = 1.1100001111 * 2**-5  = 0.000011100001111
0 01001 1100001111 = 1.1100001111 * 2**-6  = 0.0000011100001111
0 01000 1100001111 = 1.1100001111 * 2**-7  = 0.00000011100001111
0 00111 1100001111 = 1.1100001111 * 2**-8  = 0.000000011100001111
0 00110 1100001111 = 1.1100001111 * 2**-9  = 0.0000000011100001111
0 00101 1100001111 = 1.1100001111 * 2**-10 = 0.00000000011100001111
0 00100 1100001111 = 1.1100001111 * 2**-11 = 0.000000000011100001111
0 00011 1100001111 = 1.1100001111 * 2**-12 = 0.0000000000011100001111
0 00010 1100001111 = 1.1100001111 * 2**-13 = 0.00000000000011100001111
0 00001 1100001111 = 1.1100001111 * 2**-14 = 0.000000000000011100001111
0 00000 1100001111 = 0.1100001111 * 2**-14 = 0.000000000000001100001111


Denormals have no leading 1 and use the same exponent as smallest normal numbers.

To perform an addition, you need to align mantissas, then perform an addition or a subtraction (if the signs are opposite, as this is the case here.) :

  -1000000001.0
+         0.000000000000001100001111
=-1000000000.111111111111110011110001


Here the difference between the two numbers is too large and the small number will disappear after rounding, except if you use a special rounding mode (as round towards zero or towards +infinite)

Maybe you have other sample additions that are more interesting.

Using two's complement, one can make subtractions out of additions :

    -         0.000000000000001100001111
! = 1111111111.111111111111110011110000 : Invert all digits
+1 = 1111111111.111111111111110011110001 : plus one.


     1000000001.000000000000000000000000