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

Converting text in exponential form to double

P: n/a
Hi,

I have the text "5.21e-09" and I want to convert it to a double. atof()
does not seem to work, does anyone know how to convert it?

Michael

Oct 23 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
I figured this out myself. Strangely enough when I included stdlib.h
the problem was fixed.

I wonder what atof() function it was using without including this file?

Michael

Oct 23 '05 #2

P: n/a
Michael McGarry wrote:
I figured this out myself. Strangely enough when I included stdlib.h
the problem was fixed.

I wonder what atof() function it was using without including this file?

Michael


Sounds like you're using C rather than C++. In that case, atof() would
be an implicit int function.
Oct 23 '05 #3

P: n/a
On 22 Oct 2005 18:05:02 -0700, "Michael McGarry"
<mi*************@gmail.com> wrote in comp.lang.c++:
I figured this out myself. Strangely enough when I included stdlib.h
the problem was fixed.

I wonder what atof() function it was using without including this file?

Michael


DON'T use atof(), or other ato... functions. They are dangerous. They
produce undefined behavior if the converted value is outside the range
of the destination type. Also you can never tell if a value of 0 is
the result of an actual representation of 0 in the character string,
or because the string was not convertible.

If you are using stdlib.h functions, use the strto... series. They
have defined behavior for all inputs other than a null pointer, and
offer facilities for error checking.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Oct 23 '05 #4

P: n/a
Thanks for the tip.

Nov 2 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.