I'm trying to format 65.32
to become 6532
65.32 * 100
gets me 6531.999999999999
.
Why does it do that? Is it a bug? Should I change it to a string and use string manipulation instead?
I'm trying to format 65.32
to become 6532
65.32 * 100
gets me 6531.999999999999
.
Why does it do that? Is it a bug? Should I change it to a string and use string manipulation instead?
Generally speaking, if you're dealing with numbers it's usually better to stick with numbers. It makes your code more readable and easier to follow. The Math library provides what you need.
var x = 62.29933;
console.log(x*100);
x = Math.floor(62.29933*100);
console.log(x);
x = Math.ceil(62.29933*100);
console.log(x);
x = Math.round(62.29933*100);
console.log(x);