This code returns: 0.04999999999999999
var number = parseFloat(0.15);
console.log(number % 0.05);
Why?
Here is a plunk: http://plnkr.co/edit/fYa4ZpvNj3xTvgNHx0pj?p=preview
This code returns: 0.04999999999999999
var number = parseFloat(0.15);
console.log(number % 0.05);
Why?
Here is a plunk: http://plnkr.co/edit/fYa4ZpvNj3xTvgNHx0pj?p=preview
Floating point math is actually only as good as the bit width representation. For instance, 0.1 is actually 0.100000010000001.