Your Ad Here

Posted By

ctran on 07/23/07


Tagged

currency


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

korzhik


formatAsMoney


 / Published in: JavaScript
 

URL: http://www.rgagnon.com/jsdetails/js-0076.html

Convert a number to a currency format, 100 => 100.00

  1. function formatAsMoney(mnt) {
  2. mnt -= 0;
  3. mnt = (Math.round(mnt*100))/100;
  4. return (mnt == Math.floor(mnt)) ? mnt + '.00'
  5. : ( (mnt*10 == Math.floor(mnt*10)) ? mnt + '0' : mnt);
  6. }

Report this snippet  

You need to login to post a comment.