Questions about IEEE754 floating point in D
Don
nospam at nospam.com
Mon Feb 22 00:10:33 PST 2010
Trip Volpe wrote:
> 1. Does D guarantee the closest approximation for decimal floating-point literals?
Not at present.
>
> 2. Minimum exponent. In D, double.min_exp is equal to -1021. However, the Wikipedia article on IEEE754-2008 and appendix D in Sun's Numerical Computation Guide ("What Every Computer Scientist Should Know About Floating-Point Arithmetic", http://docs.sun.com/source/806-3568/ncg_goldberg.html) list Emin for the IEEE754 double format as -1022. Is this an error?
[snip]
There are no errors anywhere. However, double.min_exp is defined in the
spec as "the minimum value such that 2^^min_exp-1 is representable as a
normalized value".
This means that 2^^min_exp-1 == 2^^Emin. And indeed min_exp-1 == -1022 =
Emin.
I have no idea why min_exp is defined in such a peculiar way. In
particular, I don't know why it's different from the definition of
min_10_exp. It seems bizarre and useless.
I've had a sudden thought though -- DMC/DMD used to have an out-by-1 bug
in the %a format for denormals. Maybe this behaviour isn't intentional,
but was rather a mistake, caused by that?
Note to Walter: I changed min --> min_normal in the ddoc for my
'floatingpoint' article long ago, but it hasn't been copied into the
download.
More information about the Digitalmars-d
mailing list