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.
As stated in the blog, the Formspider framework had a Java renderer that uses DecimalFormat and we needed the same functionality on the javascript side which means formatting numbers with variable masks such as "$#,#00.0#" or "00.0##%" that is defined by the user. So sprintf is not the same.
By the way, this code was wrtiten in 2008.
7 comments
[ 3.1 ms ] story [ 29.1 ms ] threadhttp://www.diveintojavascript.com/projects/javascript-sprint...
http://code.google.com/p/jquery-numberformatter/