swie@umn-cs.CS.UMN.EDU (Swie Tsing Tan) (05/17/89)
Could someone please tell me if there is an easy way to insert commas as digits
separators for "int", "long", "longdouble", and "double", without affecting
the digit accuracy ?
For example, -123456789.12345 becomes -123,456,789.12345
111222 becomes 111,222 etc.
I have written a routine to convert "string" <-> "number", but it seems to me
that I lost some digits accuracy.
Could you please e-mail to me if you know the answer ?
Thanks in advance.
swie@umn-cs.cs.umn.edubobmon@iuvax.cs.indiana.edu (RAMontante) (05/17/89)
One approach would be to use sprintf(), itoa(), and the like to convert your values into ASCII strings (presumably without loss of accuracy), then perform string manipulations to insert comma-characters into the representations. (Hint: start with strchr()/index() to find the decimal point.)