How many numbers can a 32 bit float represent
Asked Answered
L

1

2

Using the IEEE Standard for float, how many different numbers can a 32 bit float represent?

Lorelle answered 4/10, 2020 at 18:42 Comment(0)
N
6

Each bit pattern in an IEEE-754 binary32 format represents a distinct number except:

  • Zero is represented twice, as +0 and −0. Thus, one is a duplicate.
  • Patterns with all ones in the eight-bit exponent field and a non-zero value in the 23-bit primary significand field represent a Not-a-Number (NaN). The number of these is 2•(223−1). (The initial factor of two is for the sign bit.)

There are 232 bit patterns. Subtracting the duplicate and the NaNs gives 232 − 1 − 2•(223−1) = 4,278,190,081.

Note that the above includes +∞ and −∞. To limit it to finite numbers, subtract two.

Nikolai answered 4/10, 2020 at 19:56 Comment(1)
Nice answer. Perhaps "Thus, one is a duplicate value." +/- zero is always a question if the OP wants to or does not care if they are "different numbers".Afterimage

© 2022 - 2024 — McMap. All rights reserved.