www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - floating point min, max, min_normal

reply bearophile <bearophileHUGS lycos.com> writes:
I vaguely remember Don talking about this, but I don't remember the
conclusions, and there is something strange.

In this page among the properties of floating point values the min seems
missing:
http://www.digitalmars.com/d/2.0/property.html

Yet the min is present and returns the same value as min_normal:

import std.stdio;
void main() {
    writeln(double.min);        //  2.22507e-308
    writeln(double.max);        //  1.79769e+308
    writeln(double.min_normal); //  2.22507e-308
    writeln(-double.max);       // -1.79769e+308
}

In generic code I have used min, but the min for floating point values is very
different from the min for integral values. Is it possible to change double.min
to something similar to -double.max? Otherwise I suggest to just remove
double.min, because it's confusing for me and my code.

Bye,
bearophile
Aug 11 2010
parent reply Don <nospam nospam.com> writes:
bearophile wrote:
 I vaguely remember Don talking about this, but I don't remember the
conclusions, and there is something strange.
 
 In this page among the properties of floating point values the min seems
missing:
 http://www.digitalmars.com/d/2.0/property.html
 
 Yet the min is present and returns the same value as min_normal:

min is deprecated. It is scheduled for removal. It's deliberately no longer included in the list of properties.
Aug 12 2010
parent reply bearophile <bearophileHUGS lycos.com> writes:
Don:
 min is deprecated. It is scheduled for removal. It's deliberately no 
 longer included in the list of properties.

Is -double.max really the minimum double value that can be represented before -inf? Bye, bearophile
Aug 12 2010
parent BCS <none anon.com> writes:
Hello bearophile,

 Don:
 
 min is deprecated. It is scheduled for removal. It's deliberately no
 longer included in the list of properties.
 

before -inf?

IIRC IEEE floating point uses signed magnitude so yes.
 Bye,
 bearophile

... <IXOYE><
Aug 12 2010