Java DecimalFormat implemented in JavaScript
gergerconsulting.blogspot.com
Java DecimalFormat implemented in JavaScript
1–8 of 8 posts
Re: Java DecimalFormat implemented in JavaScript
#2http://www.diveintojavascript.com/projects/javascript-sprint...
Re: Java DecimalFormat implemented in JavaScript
#3Re: Java DecimalFormat implemented in JavaScript
#4Why not just use Javascript sprintf? http://www.diveintojavascript.com/projects/javascript-sprint...
Re: Java DecimalFormat implemented in JavaScript
#5Why not just use Javascript sprintf? http://www.diveintojavascript.com/projects/javascript-sprint...
In the case of currency, it is better to use decimal arithmetic because if you use float numbers the rounding behaves different than doing the same operations by hand or in a calculator. Another option is to use integers (to represent number of cents) and just print the decimal point when displaying the number.
Re: Java DecimalFormat implemented in JavaScript
#6Earlier quoted context omitted.
In the case of currency, it is better to use decimal arithmetic because if you use float numbers the rounding behaves different than doing the same operations by hand or in a calculator. Another option is to use integers (to represent number of cents) and just print the decimal point when displaying the number.
I'm not sure if you're answering my question or not. I've inspected the source of both libraries, and they both use the JS method toFixed().
Re: Java DecimalFormat implemented in JavaScript
#7Why not just use Javascript sprintf? http://www.diveintojavascript.com/projects/javascript-sprint...
Re: Java DecimalFormat implemented in JavaScript
#8Why not just use Javascript sprintf? http://www.diveintojavascript.com/projects/javascript-sprint...