8
$\begingroup$

I am confused about how denormalized numbers work in floating point representation.

I was referring to Stallings book and this article. The book initially explains floating point number format in general and then explains IEEE 754 floating point format. I will tell explicitly when I am talking about floating point format in general and when about IEEE 754.

First let me tell you what I understand. Lets consider single precision (32 bit) numbers. As shown in the book, the normalized numbers in IEEE 754 takes following form:

enter image description here

In both general and IEEE 754 floating point number,

  • Sign bit is 0 for positive number, 1 for negative number.
  • Fraction aka significand has implicit leading 1.
  • Biased component is exponent with bias 127.

With this information, I am able to come p with range of normalized numbers in IEEE 754 standard. Its $\pm2^{-126}$ to $(2-2^{-23})\times 2^{127}$ as given in that article. This is how I interpret, how its derived.

  • Max significand: $(1.\underbrace{11..11}_{23\text{ bits}})_2=(2-2^{-23})_{10}$
  • Min significand: $(1.\underbrace{00..00}_{23\text{ bits}})_2=(1)_{10}$ and is simply omitted from multiplication to $\pm2^{-126}$
  • Min exponent: Biased: $(00000001)_2=(1)_{10}$, Unbiased: $1-127=-126$
  • Max exponent: Biased: $(11111110)_2=(254)_{10}$, Unbiased: $254-127=127$

I know that significand in de-normalized range does not have implicit leading 1 and in fact has leading 0.

Doubts

I have following doubts about denormalized range in IEEE 754 format:

  1. As give in that article, how is the denormalized single precision range is $\pm 2^{-149}$ to ${(1-2^{-23})\times2^{-126}}$

  2. Consider below table from Stallings book. In this, in the biased exponent column, entries for positive and negative denormalized (last two) rows is $0$, but in the value column, the exponent of $2$ is $e-126$, even though there is no $e$ elsewhere in those rows.

    enter image description here

  3. Now consider the below table given under summary section of that article. Note that in 2nd row and 5th last row of denormalized real, "Exponent" column says $00..00$, however in value column, there is $+1$ in the exponent: $2^{(-b\color{red}{+1})}$. From where this $+1$ came?

  4. How exponents in the book (as explained in the question 2) and the exponent in the article (as explained in the question 3) compare and how they lead to the range asked in question 1?

    enter image description here

$\endgroup$
3
  • 1
    $\begingroup$ 2^-149 = (2^-23) * (2^-126). $\endgroup$
    – gnasher729
    Dec 16, 2018 at 14:56
  • $\begingroup$ @gnasher729 great!!!, but why $2^{-126}$? I am interpreting it as follows: $\underbrace{0}_{\text{(sign bit)}}\underbrace{00..00}_{\left(\text{8 bit exponent}\right)}\underbrace{00..01}_{\left(\text{23 bit significand}\right)}$. 8 bit exponent is biased one. Unbiased one will be $0-127=-127$. So the exponent will be $2^{-127}$. The significand have only 23rd/last bit set to 1. Rest all are zero. This will give significand $2^{-23}$. So the shouldnt the min value of de normalized one be $2^{-23}\times 2^{-127} = 2^{-150}$? $\endgroup$
    – RajS
    Dec 16, 2018 at 15:43
  • $\begingroup$ @gnasher729 So let me rephrase. Why there is +1 in $-b\color{red}{+1}$ in "Positive denormalised real"'s cell? Is it standard defined. And if yes, does that mean the bias for de normalized / subnormal number is one less than that in case of normalized number? (Found this archive of various revisions draft of IEEE754 standard. The latest one also does not seem to say much!!!) $\endgroup$
    – RajS
    Jan 5, 2019 at 6:25

1 Answer 1

9
$\begingroup$

Although, the question is a bit old, but it may help people coming here for similar question.

A vital detail was missed out in the article that you referred to and it is that the standard chose to interpret an all 0s exponent to be equivalent to '-126' and not '-127'. One place, where I found a nice explanation (and an explicit statement about this truth) is this article. To quote from it:

Subnormal Numbers: When all the exponent bits are 0 and the leading hidden bit of the siginificand is 0, then the floating point number is called a subnormal number. Thus, one logical representation of a subnormal number is

(–1)s × 0.f × 2–127 (all 0s for the exponent) ,

where f has at least one 1 (otherwise the number will be taken as 0). However, the standard uses –126, i.e., bias +1 for the exponent rather than –127 which is the bias for some not so obvious reason, possibly because by using –126 instead of –127, the gap between the largest subnormal number and the smallest normalized number is smaller.

The largest subnormal number is 0.999999988×2–126. It is close to the smallest normalized number 2–126.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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