javascript - Convert float and maintain decimal places -
i have values:
var = 20.0; document.write(a); --> 20 document.write(a.tofixed(2)); --> "20.00"
i want know if possible maintain decimal places , variable float?
something this:
20.00
the kind of floating point numbers used javascript (ieee-754) don't maintain "precision" value of kind (e.g., "20.00
" has 2 zeroes after decimal, "20.000
" has three). trailing zeroes after decimal point not significant.
there style of number doing in environments (java has bigdecimal
, c# has decimal
), nothing built javascript does. believe there's bigdecimal
port javascript out there.
Comments
Post a Comment