below is the code,
if(3.0+0.1 == 3.1){
return true;
}
else{
return false;
}
Can anyone tell me why it is returning false.
below is the code,
if(3.0+0.1 == 3.1){
return true;
}
else{
return false;
}
Can anyone tell me why it is returning false.
This is because 3.0+1
makes the following equation: 3.0 + 1.0 === 3.1
which isn't true try 3.0 + 0.1 === 3.1
or a more safer option (due to how floats work)
(30 + 1) / 10 === 3.1