By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,745 Members | 1,873 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,745 IT Pros & Developers. It's quick & easy.

How to convert decimal string to float?

P: n/a
I have a string representing a decimal value like 123.456 (or -90.4005 etc.) and I need to represent it by a float datatype (4 bytes). What is the math used to do so? When I Google all I can find are calculators that do it for you but I have to implement it on a microcontroller. Thanks.
Oct 6 '10 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 5K+
P: 9,197
Are you using C or C++?

If it's C, then call atof().

If it's C++, insert your string into a stringstream and extract it to a double.
Oct 6 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.