This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

code for converting float to string

Is there any library function in KEIL C which converts a floating point into string. If not can somebody give the appropriate code.

Parents
  • Why reinvent the wheel ?

    sprintf() (and scanf()) are big and slow. Occasionally, for some limited applications, it can be worthwhile to write custom parsing or output that doesn't have to handle all of the data types and formatting options of the library routines.

    But it's rarely worth the effort.

Reply
  • Why reinvent the wheel ?

    sprintf() (and scanf()) are big and slow. Occasionally, for some limited applications, it can be worthwhile to write custom parsing or output that doesn't have to handle all of the data types and formatting options of the library routines.

    But it's rarely worth the effort.

Children
  • sprintf() (and scanf()) are big and slow. Occasionally, for some limited applications, it can be worthwhile to write custom parsing or output that doesn't have to handle all of the data types and formatting options of the library routines.

    But it's rarely worth the effort.

    why worry about "sprintf() (and scanf()) are big and slow" once you have already lost any illusion of performance by using floating point with a '51?

    Erik

  • If scanf() is big and slow, check for the availability of atof() or strtod().

    If sprintf() is big and slow, check for the availability of ecvt(), fcvt() or gcvt() functions.

    The scanf() and sprintf() functions are normally never implemented monolitically. They normally makes use of helper functions like the above suggestions, and they may be used directly.

    By the way, don't stop using scanf() because it is large or slow. Stop using it because it is quite lousy. It has a tendancy to be dangerous. It has a tendancy to leave data in the input buffer. It only returns the number of converted arguments - not the location of the first erroneous character. It isn't always obvious how to write the formatting string, to handle non-convertable data in the input string.

  • "check for the availability of atof() or strtod() ... ecvt(), fcvt() or gcvt"

    www.google.com/codesearch