Posted By

Phoenicia7 on 05/14/12


Tagged


Versions (?)

Commify


 / Published in: TCL
 

  1. proc _commify {num {sep ,}} {
  2. # commify --
  3. # puts commas into a decimal number
  4. # Arguments:
  5. # num number in acceptable decimal format
  6. # sep separator char (defaults to English format ",")
  7. # Returns:
  8. # number with commas in the appropriate place
  9. #
  10.  
  11. while {[regsub {^([-+]?\d+)(\d\d\d)} $num "\\1$sep\\2" num]} {}
  12. return $num
  13. }
  14.  

Report this snippet  

You need to login to post a comment.