This may be a noob question to ask. It is about Math.pow
in JavaScript.
var amount = 0.55;
var decimal = 18;
var value = amount * Math.pow(10, decimal);
console.log('amount: ' + amount + ' value: ' + value);
If the amount is 0.55,I expected the returned value to be 550000000000000000
.
But, instead it returns 550000000000000060
If the amount is 0.56,I expected the returned value to be 560000000000000000
.
But, instead it returns 560000000000000060
How do I get the expected returned value and why does it happen?