First, to make your life easier, always work with the absolute value of the number. This will make your life easier, and then you can put on the negative sign later, as necessary.
Steps:
A. Use sprintf to print the number as a decimal into a text buffer.
B. Count the number of digits. If <= 3, you are done.
C. Calculate the modulus of the count of digits and 3. Something like this:
D. If that result is 0... change it to 3.
E. The value you obtained will tell you how many digits to copy before the first comma. From there, you just copy three digits at a time from the first text buffer to another text buffer, then insert a comma.
Example:
(A) Number = 11614127
(B) Number of digits = 8
(C) 8 % 3 = 2;
(D) Okay
(E) That means, copy 2 digits "11". Then copy a comma, then 3 digits "614" then another comma, then 3 more digits "127".
I'll leave the coding up to you, but thisis the method I'd use.
I REALLY hope that helps.
Will