0
$\begingroup$

Denormalized numbers can represent numbers smaller than 2^(-1022) whereas normalized number cannot. So I'm curious what happens if we add denormalized number and normalized number. Actually, I have tried some tests and it seems that the computer converts denormalized number to 0. Is my thought correct?

$\endgroup$
2
$\begingroup$

The result depends on the difference between the normal and denormal numbers you are adding. $1 + [denormal]$ is rounded to $1$.

But if the range difference between your numbers is inferior to $2^{52}$ for doubles, or $2^{23}$ for singles, you will get a real addition. There is nothing special about denormals here : $1 + 2^{-200}$ is rounded to $1$ as well.

To implement a floating point adder (as hardware or software), you shift right the smaller number to equalize the exponents before doing an integer addition to the aligned mantissas. If the range difference is too large, the smaller number is entirely shifted out.

$\endgroup$
  • $\begingroup$ Can you explain me why the range difference determines everything? $\endgroup$ – Jin Mar 12 '16 at 11:40
  • $\begingroup$ The result must fit in a fixed number of bits, 52 for doubles and 23 for singles. You can try doing the addition manually (with singles, it is easier). $\endgroup$ – TEMLIB Mar 12 '16 at 13:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.