473,509 Members | 2,671 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to convert decimal string to float?

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
1 1988
weaknessforcats
9,208 Recognized Expert Moderator Expert
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

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

Similar topics

4
17664
by: Ken Varn | last post by:
I have an unknown numeric Type object passed into a function. I want to run a conversion on a string to convert the string to that Type object and return an object of that type. Is there some way...
4
78757
by: STom | last post by:
How do you convert a string in C# to decimal? STom
13
9197
by: Jason | last post by:
Could someone here show me how I would write a vb program to convert decimal ip address to binary? For example a small form with a convert button and a label for the result and a textbox for the...
13
5567
by: muss | last post by:
how to convert decimal number in a hexadecimal number using C? Please help me. Thanks.
6
3955
by: Mark Chimes | last post by:
Hi All, I need to search thru some strings and discard them if they canot be converted to a decimal or interger value. What is the best way to do this? cheers, Mark Chimes
2
2195
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - Why does 1+1 equal 11? or How do I convert a string to a number?...
4
1458
by: Yuan HOng | last post by:
Hi, It seems decimal object will always be larger than float in comparasion, which goes against common sense: False True It seems to me that rather than allowing this to happen,...
0
798
by: Wojciech Walczak | last post by:
2008/5/6, Yuan HOng <hongyuan1306@gmail.com>: Looks like a nasty bug. a 99999.0 returns True because NotImplemented 99999.0 returns True. a < 99999.0 returns False because NotImplemented <...
1
2956
by: Vitaliy | last post by:
Hi I got this wired exception periodically (Python 2.5, Django based application) what does it mean ?
0
7135
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7342
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7505
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5650
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5060
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4729
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3215
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3201
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
774
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.