Efficient way to transform float to string

Robert Nelson Gasch rg2c+ at andrew.cmu.edu
Fri Dec 7 17:14:25 AEST 1990


Hi,
I'm looking for an *efficient* algorithm to transform a float (10< f < 0)
into a string. What I am doing right no is this:

I get the first digit and put the appropriate number in array[0]. 
Array[1] gets the decimal point. I then make f < 1 and multiply it
times 10, and get the aproriate character for the first digit and 
repeat this procedure until the number equals 0. Sounds OK, but when
you do this alot, it's pretty damn slow.

If anybody has any suggestions on how to do this faster, please let me
know. Both actual code or algorithm descriptions are welcome.

Thanx alot --> Rob



More information about the Comp.lang.c mailing list