Reputation: 1
I want to confirm it that the significand representation in double data type in C is always a fraction between 0 and 2 with a 2^52 precision as per the IEEE 754 standard.
Here is where I read that: https://stackoverflow.com/questions/30052710/why-double-can-store-bigger-numbers-than-unsigned-long-long#:~:text=The%20reason%20is%20that%20unsigned,10308)%20but%20not%20exactly.
Upvotes: 0
Views: 171
Reputation: 222323
I want to confirm it that the significand representation in double data type in C is always a fraction between 0 and 2 with a 2^52 precision as per the IEEE 754 standard.
No, it is not. The C standard does not require that conforming C implementations use the IEEE-754 binary64 format (also called “double precision”) for the double
type.
The C standard describes floating-point numbers as having significands in [0, 1), because it uses a form in which all the significant digits are to the right of the radix point. However, this is simply a matter of scaling and is mathematically equivalent to the more commonly used form in which the first digit is to the left of the radix point. Since this form is suggested by the interval you ask about, [0, 2), this answer uses that form.
Also, “the significand representation” is different from “the significand.” The mathematical significand of an IEEE-754 binary64 number is in [0, 2) (the interval including 0 but excluding 2) for finite numbers. (And it is in [0, 1) for subnormal numbers and [1, 2) for normal numbers.) However, the significand representation is a string of 52 bits combined with one bit from the exponent field. (That bit from the exponent field is 0 if the exponent field is all zeros and 1 if the exponent field is neither all zeros nor all ones. If it is all ones, the significand is not applicable because it is representing an infinity or NaN.)
Further, +∞ and −∞ (plus and minus infinity) are representable numbers in the binary64 format but do not have significands in [0, 2). And the format also provides for representing NaN (Not a Number), which does not have a significand value (although the significand field may provide useful information).
If a C implementation uses IEEE-754 binary64 for double
(or any format using base two), and the “value” of a double
is a finite number, then its significand is in [0, 2).
Also note that “2^52 precision” is not a good term, at least not without some definition of what that means. What is 3 precision or 8 precision? A number by itself has little meaning. 252 is the ratio between the position values of the most and least significant bits in the significand, although subnormal numbers are unable to maintain that span.
Upvotes: 3