K
Kevin
Anyone has a idea of the max/min "operatable" double value?
By "operatable/comparable", I mean: we can add/minus a value from it
and get a different value.
The problem of Double.MAX_VALUE and Double.NEGATIVE_INFINITY are:
double d1 = Double.NEGATIVE_INFINITY;
double d2 = d1 + 100;
System.out.println(d1);
System.out.println(d2);
double d3 = Double.MAX_VALUE;
double d4 = d3 - 10000;
System.out.println(d3);
System.out.println(d4);
if (d3 > d4)
System.out.println("d3 is bigger.");
And the output will be:
-Infinity
-Infinity
1.7976931348623157E308
1.7976931348623157E308
See: minus 1000 from Double.Max_Value will NOT get a smaller value than
itself. So in this sensense, the Double.Max_Value is just a
none-operatable special "marker" value there.
I guess this has something to do with the floating representation
Double has.
For specific reasons: I need to define a "double" class which has some
special numbers, and behaviors as:
-MaxValue < specialNumberA < specialNumberB < "normal" range values <
specialNumberD < +MaxValue
But since the above code has shown that "Double.MAX_VALUE =
Double.MAX_VALUE -1000", I am not sure how to do it.
Any idea or where I am wrong at this?
Thanks.
By "operatable/comparable", I mean: we can add/minus a value from it
and get a different value.
The problem of Double.MAX_VALUE and Double.NEGATIVE_INFINITY are:
double d1 = Double.NEGATIVE_INFINITY;
double d2 = d1 + 100;
System.out.println(d1);
System.out.println(d2);
double d3 = Double.MAX_VALUE;
double d4 = d3 - 10000;
System.out.println(d3);
System.out.println(d4);
if (d3 > d4)
System.out.println("d3 is bigger.");
And the output will be:
-Infinity
-Infinity
1.7976931348623157E308
1.7976931348623157E308
See: minus 1000 from Double.Max_Value will NOT get a smaller value than
itself. So in this sensense, the Double.Max_Value is just a
none-operatable special "marker" value there.
I guess this has something to do with the floating representation
Double has.
For specific reasons: I need to define a "double" class which has some
special numbers, and behaviors as:
-MaxValue < specialNumberA < specialNumberB < "normal" range values <
specialNumberD < +MaxValue
But since the above code has shown that "Double.MAX_VALUE =
Double.MAX_VALUE -1000", I am not sure how to do it.
Any idea or where I am wrong at this?
Thanks.