Given:
double x = 1.0;
the value of x is exactly 1.0, no more, no less. What that value
*means*, whether it's just that specific value or any arbitrary value
in some specified range, depends on the application.
If you think otherwise, please cite wording in the standard that
contradicts what I just wrote.
There was a thread a long time ago when this was discussed.
Are Floating Point Constants "constant" from 1998.
Updated to N1124:
N1124 has the following.
----------------------------------
6.4.4.2 Floating constants
3 The significand part is interpreted as a (decimal or hexadecimal)
rational number; the digit sequence in the exponent part is
interpreted as a decimal integer. For decimal floating constants, the
exponent indicates the power of 10 by which the significand part is
to be scaled. For hexadecimal floating constants, the exponent
indicates the power of 2 by which the significand part is to be
scaled.
====>
For decimal floating constants, and also for hexadecimal floating
constants when FLT_RADIX is not a power of 2, the result is either
the nearest representable value, or the larger or smaller
representable value immediately adjacent to the nearest representable
value, chosen in an implementation-defined manner.
<====
For hexadecimal floating constants when FLT_RADIX is a power of 2, the
result is correctly rounded.
----------------------------------
My reading of this is that
x=1.0;
can result in
x==1.0
x==the next smaller representable value to 1.0
x==the next larger representable value to 1.0
I assume that what you wrote was what was intended, but my DS9000
doesn't produce the results you expect.
c89 seems to agree with you:
--------------------------------------
3.1.3.1 Floating constants
The value part is interpreted as a decimal rational number; the
digit sequence in the exponent part is interpreted as a decimal
integer. The exponent indicates the power of 10 by which the value
part is to be scaled.
====>
If the scaled value is in the range of representable values (for its
type) but cannot be represented exactly, the result is either the
nearest higher or nearest lower value, chosen in an
implementation-defined manner.
<====
--------------------------------------
It appears that an important distinction got lost in the wording
change. Maybe somebody should submit a DR.
Regards,
Bruce Wheeler