Possible Duplicate:
Is JavaScript’s Math broken?
I'm running a few very basic functions in javascript to try and convert a float to a currency. For example:
var t = Array(15.90, 15.95, 15.95);
var x = t[0];
if(x%1 == 0)
output += ".0";
if(x%.1 == 0)
output += "0";
Output should yield 0
, but for some reason, in some cases, this won't work and when I echo the value of x to the console, I'll either get 15.89999999999
or 15.900000000001
. Why?
Thanks for your help.