Float to String

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,
I have to convert a Float to a string, but I didn´t find any function for
this. Has someone an idea, how to do this.

If its too difficult I could also use a function which converts an integer
to an string. I have found a function in stdlib.h "itoa" but it doesn´t work.
Perhaps I have used the wrong parameters. How must I use this function?

Regards
Thomas

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Check the projects. I added a C routine that does this without needing libraries.

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What I'd done was simple - i designed a int2str function and multiplied the float 10x or 100x or whatever precision I needed, then converted the float to int, then fed it into int2str, indicating that the last 1 or 2 digits should be behind the dot .. easy as pie ;)

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Wow, that is great!
Thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You do realise you are replying to thread that's more than 8 years old?

Moderator.

(and I'm not entirely sure I see what's "great!" about the OP anyway?)