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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -