L
lcw1964
Greetings again,
I will burden the group with yet another tenderfoot question, but since
conscientious googling hasn't yield a lucid answer I thought I would
risk the shortcut of asking here since I am so very keen to learn to
code in standard C.
Could someone tell me the long double equivalent of atof()? I was
getting some peculiar behaviour in a little bit of math code I am
working with. I thought the problem was in the math algorithms, but not
so--it is the input interface. I get my desired numeric input with
gets(), put it to a character string txt, and put it into a long double
variable x with x = atof(x).
But a little testing as revealed that when the string txt actually
represents a numeral outside of the double range, atof() translates it
not to its long double equivalent, but inf. For example the entered
text string 1e500 is not converted to the long double quantity
1.0E500L, but, as I said, inf.
What is the appropriate ANSI C approach to this? I am aware of
non-standard functions such as atold() or _atold() in other compilers,
but I want to be good boy and speak standard C.
Many thanks for your patient assistance.
Les
I will burden the group with yet another tenderfoot question, but since
conscientious googling hasn't yield a lucid answer I thought I would
risk the shortcut of asking here since I am so very keen to learn to
code in standard C.
Could someone tell me the long double equivalent of atof()? I was
getting some peculiar behaviour in a little bit of math code I am
working with. I thought the problem was in the math algorithms, but not
so--it is the input interface. I get my desired numeric input with
gets(), put it to a character string txt, and put it into a long double
variable x with x = atof(x).
But a little testing as revealed that when the string txt actually
represents a numeral outside of the double range, atof() translates it
not to its long double equivalent, but inf. For example the entered
text string 1e500 is not converted to the long double quantity
1.0E500L, but, as I said, inf.
What is the appropriate ANSI C approach to this? I am aware of
non-standard functions such as atold() or _atold() in other compilers,
but I want to be good boy and speak standard C.
Many thanks for your patient assistance.
Les