Tuesday, February 3, 2009

Let's Talk about .. Java Script-Convert to n-decimal-point number

If you want to set your number to be n-decimal-point number, you can use toFixed(n) function. I fount this methos in http://www.mredkj.com/javascript/nfbasic2.html For example,

[Java Script]
//Input: 1234 or 123.4
//Output: 1234.00 or 123.40
yourNumber = num.toFixed(2);

No comments: