double.min - should be 5e-324?
Don
nospam at nospam.com
Sat Dec 4 21:56:21 PST 2010
Dmitry Olshansky wrote:
> Well, to keep things short, double.min returns something weird.
> See the following for demonstration:
> import std.stdio;
>
> void main(){
> double r = double.max, r2 = double.min;
> writeln(r);//1.79769e+308
> r *= 2;//test if it's max
> writeln(r); // infinity, ok
>
> writeln(r2);//2.22507e-308, wtf ?
> r2 /= 2.0;
> writeln(r2);// 1.11254e-308, a logical consequence of above
>
> double dmin = 5e-324;
> writeln(dmin);// 4.94066e-324
> dmin /= 2.0;
> writefln(dmin);// 0
> }
>
double.min is deprecated, for exactly this reason. That's why it's not
mentioned in the spec.
More information about the Digitalmars-d
mailing list