In the program below, the result is that 0.0
is considered less than Double.MIN_VALUE
. Why?
We have a solution (work with Doubles
only and use compareTo
) and I want to understand why unboxing is failing here.
import java.util.Date;
import java.util.Calendar;
import java.math.BigDecimal;
public class Test {
public static void main(String[] args) {
double max = 99999.9999;
double min = Double.MIN_VALUE;
Double test = 0.0;
System.out.println(max > test); // expect true; is true
System.out.println(test > min); // expect true; is false
}
}
According to the Javadocs :
MIN_VALUE
A constant holding the smallest positive nonzero value of type double, 2-1074.
In other words, it is bigger than 0.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With