You need to format a number for printing with commas (or other locale-dependant marks) in the appropriate places. This is important for creating human-legible print copies of reports.
Use the Perl-compatible regular expression engine to insert the commas where needed. It's simplest to reverse the string prior to the regexp-pass so that we can hop over any decimal portion. Then reverse the string back on return.
While this function works, it would be better if it checked the types of its input arguments to deal with the case of an input string, or someone passing the separator parameter as a character (rather than a string).
It would also be better if a version was available that only partitioned numbers the decimal point, although this is easy enough to implement with regular expressions. Ie: I would usually rather have a result of 1,928,828.12345 than 1,928,828.12,345.
Here's an example of partition-number in action: