1
Hello,
Because the comparison (0.0015 * 3) == 0.0045
in javascript does not return true?
Ex.:
var valor1 = 0.0015 * 3;
var valor2 = 0.0045;
if(valor1 == valor2) {
console.log('Igual');
} else {
console.log('Diferente');
}
1
Hello,
Because the comparison (0.0015 * 3) == 0.0045
in javascript does not return true?
Ex.:
var valor1 = 0.0015 * 3;
var valor2 = 0.0045;
if(valor1 == valor2) {
console.log('Igual');
} else {
console.log('Diferente');
}
Browser other questions tagged javascript
You are not signed in. Login or sign up in order to post.
You can also see more details: https://answall.com/q/38138/101
– Maniero
Because
0.0015 * 3
results in0.0045000000000000005
– Jéf Bueno
@bigown has the same https://answall.com/q/154189/18246
– Jéf Bueno
if you make up to the 17th decimal place you will give EQUALS if( valor1.toFixed(17) == valor2.toFixed(17) ː see https://repl.it/KOZh/0
– user60252
For the same reason that 0.1 + 0.1 is not 0.2, watch the video of the Infinite Series channel (in English): https://youtu.be/pQs_wx8eoQ8
– Jefferson Quesado