Efficient way to transform float to string

Peter Holditch peterh at hemel.bull.co.uk
Sat Dec 8 00:06:40 AEST 1990


rg2c+ at andrew.cmu.edu (Robert Nelson Gasch) writes:

>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:

> [ Stuff Deleted ]

>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

It may be that you don't consider it efficient enough, but why not just use

char fltno[12];

...

sprintf (fltno,"%10f",your_float);

That's what I'd do anyway.

Peter Holditch.

--

           #       #       #       #       #       #      #        
          # #     # #     # #     # #     # #     # #    # #        
         #   #   #   #   #   #   #   #   #   #   #   #  #   #        
        #      #       #       #       #       #       #     #
       #	From:	Peter.Holditch at hemel.bull.co.uk	      #
       #		Tel:	0442-232222x4826	      #
        #      #       #       #       #       #       #     #
         #   #   #   #   #   #   #   #   #   #   #   #  #   #        
          # #     # #     # #     # #     # #     # #    # #        
           #       #       #       #       #       #      #        

<< If I said it, it was nobody else but me. >>



More information about the Comp.lang.c mailing list