11

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

RajS
  • 1,737
  • 5
  • 28
  • 50

1 Answers1

9

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.

bbv
  • 191
  • 1
  • 3