double.min - should be 5e-324?

sybrandy sybrandy at gmail.com
Sat Dec 4 14:51:38 PST 2010


On 12/04/2010 04:22 PM, 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
> }
>

Perhaps this link can help:

https://secure.wikimedia.org/wikipedia/en/wiki/IEEE_754-1985

Casey


More information about the Digitalmars-d mailing list