## digitalmars.D - double.min - should be 5e-324?

• Dmitry Olshansky (18/18) Dec 04 2010 Well, to keep things short, double.min returns something weird.
• so (5/8) Dec 04 2010 That is something weird, you get a double smaller than the smallest
• so (4/4) Dec 04 2010 See what you mean, but it is the standard value from c's float.h.
• Dmitry Olshansky (5/11) Dec 04 2010 To prove the above point.
• Dmitry Olshansky (5/21) Dec 04 2010 the last line should be:
• Ellery Newcomer (3/19) Dec 04 2010 looks like double.min is returning double.min_normal
• sybrandy (4/20) Dec 04 2010 Perhaps this link can help:
• Don (3/23) Dec 04 2010 double.min is deprecated, for exactly this reason. That's why it's not
• Don (4/27) Dec 04 2010 And futher -- double.min_normal is the smallest normalised double. The
```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
}

--
Dmitry Olshansky
```
Dec 04 2010
``` writeln(r2);//2.22507e-308, wtf ?

What is wrong? It is the smallest representable double. not (-double.max)

r2 /= 2.0;
writeln(r2);// 1.11254e-308, a logical consequence of above

That is something weird, you get a double smaller than the smallest
representable!

--
Using Opera's revolutionary email client: http://www.opera.com/mail/
```
Dec 04 2010
```See what you mean, but it is the standard value from c's float.h.

This is not my day, i should just stop posting...

--
Using Opera's revolutionary email client: http://www.opera.com/mail/
```
Dec 04 2010    Dmitry Olshansky <dmitry.olsh gmail.com> writes:
```On 05.12.2010 0:48, so wrote:
writeln(r2);//2.22507e-308, wtf ?

What is wrong? It is the smallest representable double. not (-double.max)

The smallest is 5e-324 as I (hopefully) showed.

r2 /= 2.0;
writeln(r2);// 1.11254e-308, a logical consequence of above

That is something weird, you get a double smaller than the smallest
representable!

To prove the above point.

--
Dmitry Olshansky
```
Dec 04 2010
```On 05.12.2010 0:22, 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
}

the last line should be:
writeln(dmin); //0

--
Dmitry Olshansky
```
Dec 04 2010
```On 12/04/2010 03: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
}

looks like double.min is returning double.min_normal

oddly enough, double.min is undefined in the spec
```
Dec 04 2010
```Ellery Newcomer wrote:
looks like double.min is returning double.min_normal

oddly enough, double.min is undefined in the spec

Yeah, things got changed a while back for floating point types. .min now
returns the minimum normal. To get the actual minimum value, we need to
use the negative of .max.

Ali
```
Dec 04 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
}

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

Casey
```
Dec 04 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.
```
Dec 04 2010
```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.
```
Dec 04 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
```
Dec 05 2010