How the less than or equal to condition checking performed on a Double variable.
I have two variable first, second.
Double first = 20.0;
Double second = 20.0;
if(first <= second){
//This is not going inside the if part
}
How the less than or equal to condition checking performed on a Double variable.
I have two variable first, second.
Double first = 20.0;
Double second = 20.0;
if(first <= second){
//This is not going inside the if part
}
Probably inherent inaccuracy of floating point representations. See Why am I getting the wrong result when using float? among many other similar questions
Not sure if this is the case, but floating points are never represented exactly in memory. Though, the two value are very close to each other, it may happen that first is slightly greater than second, causing the if condition to be false.