double.min - should be 5e-324?
Dmitry Olshansky
dmitry.olsh at gmail.com
Sun Dec 5 03:30:47 PST 2010
On 05.12.2010 8:59, Don wrote:
> Don wrote:
>> 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.
>
> And futher -- double.min_normal is the smallest normalised double. The
> smallest representable double is (double.min_normal * double.epsilon).
>
> double.min is a silly name, so it has been deprecated.
I see, thanks for the explanation.
--
Dmitry Olshansky
More information about the Digitalmars-d
mailing list