toFixed(2) rounds "x.525" inconsistently?

Floating point inaccuracy means that most numbers ending .525 are actually .52500..1, and others are .5249999.....

Which way the value rounds depends on whether the closest actual representation in IEEE-754 floating point is above or below the desired value.


Instead of toFixed() use Math.ceil() , Math.floor() or Math.round()

with a way around like

var rnum = 5.525,
    decimalPlaces = 2,
    factor = Math.pow(10, decimalPlaces),
    newnumber = Math.round(rnum * factor) / factor,
    mydecimalvalue = parseFloat(newnumber); 

the result is 5.53