I have:
var a = 0.0532; var b = a * 100;
b should be returning 5.32 but instead it's returning 5.319999999999999. How do I fix this?
JSFiddle here: http://jsfiddle.net/9f2K8/
you should use .toFixed()
FIDDLE
var a = 0.0532; var b = a * 100; b.toFixed(2); //specify number of decimals to be displayed
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With