JavaScript multiplying by 100 giving weird result

javascript, multiplication

Solution

you should use `.toFixed()`

FIDDLE

var a =  0.0532;
var b =  a * 100;
b.toFixed(2);     //specify number of decimals to be displayed

Problem

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/

Original source

Related problems