Commatose

Commatose makes it easy to insert commas into your numbers. Commatose extends the Fixnum, Bignum and Float classes with a new method called "to_sc", which is short for "To string with comma".

The code itself is extremely simple. Here's an example:

1234567.to_sc
>1,234,567

Commatose also allows you to use a character other than a comma to separate the number.

1234567.to_sc(" Chunky bacon! ")
>1 Chunky bacon! 234 Chunky bacon! 567

In addition, you can change the number of digits within each comma separated section.

1234567.to_sc(",", 2)
>1,23,45,67

See the RDoc for more information.

The views and commentary contained on this site are completely silly. They should not be taken seriously by anyone. Ever.

This site is designed with recent versions of Mozilla Firefox in mind. If you are a heathen are using some other browser, then please consider downloading Firefox. If you are using Internet Explorer 6 or earlier, you are probably Amish. In which case, what are you doing browsing the internet!?!?!? GET BACK TO WORK!!!