I have the following function:
var a = 0.1;
var b = 0.2;
function checkValue(){
if(a + b === 0.3){
alert('statement is true');
}
else {
alert('statement is false');
}
}
checkValue();
This function evaluates to false?? Here is fiddle
Now, the same function with different decimals that also equal 0.3:
var a = 0.15;
var b = 0.15;
function checkValue(){
if(a + b === 0.3){
alert('statement is true');
}
else {
alert('statement is false');
}
}
checkValue();
evaluates to true.
Has anyone run into this before? If so are there languages commonly used for web applications that do not do this?