Posted By

ecavazos on 01/22/08


Tagged

money round cents


Versions (?)

Round Cents


 / Published in: JavaScript
 

  1. function roundCents(amount) {
  2. cents = amount * 100;
  3. cents = Math.round(cents);
  4.  
  5. str = "" + cents;
  6. len = str.length;
  7.  
  8. return str.substring(0, len - 2) + "." + str.substring(len - 2, len);
  9. }

Report this snippet  

You need to login to post a comment.