Discussion:
1.3.12-2 : atof() always returns 0
Hervé Le Net
2002-07-12 08:32:56 UTC
Permalink
Hi,

The atof() function, compiled with gcc, always returns 0.

Example :

f = atof("123.456");
printf("%f\n", f);

Result :
0.000000

Regards,
H. Le Net

_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com
Tim Prince
2002-07-12 13:02:12 UTC
Permalink
Post by Hervé Le Net
Hi,
The atof() function, compiled with gcc, always returns 0.
f = atof("123.456");
printf("%f\n", f);
0.000000
Regards,
H. Le Net
Do you mean you compiled atof(), or that you compiled some code fragment of
your own which calls atof(), possibly without employing the correct headers?
gcc conforms to the C standard, not to the usual practice prior to 13 years
ago.
--
Tim Prince

--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
Dr. Volker Zell
2002-07-12 13:03:59 UTC
Permalink
hlenet> Hi,
hlenet> The atof() function, compiled with gcc, always returns 0.

hlenet> Example :

hlenet> f = atof("123.456");
hlenet> printf("%f\n", f);

hlenet> Result :
hlenet> 0.000000

Hi

I'm wondering wether this is the reason for the failing test of libslang

o slang-1.4.5 - http://www.s-lang.org/ - ftp://space.mit.edu/pub/davis/slang/v1.4/

Whereas it doesn't fail the test with cygwin-1.3.10.

cd src; make runtests
make[1]: Entering directory `/usr/local/src/slang-1.4.5/src'
cd test; make CC="gcc" CFLAGS="-g -O2 -fno-strength-reduce" TCAPLIB=""
make[2]: Entering directory `/usr/local/src/slang-1.4.5/src/test'

Running tests:

Testing syntax ...Ok
Testing sscanf ...S-Lang Traceback: (Error occurred on line 40)
S-Lang Traceback: test_atof
File: sscanf.sl
Local Variables:
$0: Type: Double_Type, Value: -1.82703
$1: Type: Undefined_Type, Value: Undefined_Type
$2: Type: String_Type, Value: "-1.8270318497395046097864224066142924129962920000000000000000000000e+00"
$3: Type: String_Type, Value: "-1.8270318497395046097864224066142924129962920000000000000000000000E+00"
S-Lang Traceback: (Error occurred on line 75)
S-Lang Traceback: (Error occurred on line 72)
S-Lang Traceback: loop
S-Lang Traceback: (Error occurred on line 61)
S-Lang Traceback: test_atof_main
File: sscanf.sl
Local Variables:
$0: Type: Integer_Type, Value: 1000
$1: Type: Double_Type, Value: -91.5717
$2: Type: Double_Type, Value: -1.70002
$3: Type: Double_Type, Value: -1.82703
S-Lang Error: Internal Error: called from line 81, file: sscanf.sl
Testing looping constructs ...Ok
Testing Arithmetic ...Ok
Testing array functions ...Ok
Testing string functions...Ok
Testing Binary Strings...Ok
Testing pack and unpack functions...Ok
Testing stdio routines...Ok
Testing Associative Arrays ...Ok
Testing recursive function modifications ...Ok
Testing structures ...Ok
Testing NameSpace routines ...Ok
Testing ospath ...Ok
Testing #ifeval ...Ok
Testing Any_Type ...Ok
Testing Matrix Multiplications ...Ok
touch sltest.c
make[2]: Leaving directory `/usr/local/src/slang-1.4.5/src/test'
make[1]: Leaving directory `/usr/local/src/slang-1.4.5/src'


Ciao
Volker


--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
John Vincent
2002-07-12 16:19:01 UTC
Permalink
Hi,

Before you start running away too far ...

atof() returns the correct value once you
have the line "#include <stdlib.h>" at the
top of the source file.

But don't be embarassed, I've been writing in
'C' for 20 years, and I looked twice before
realising what the problem was.

Cheers,
/John Vincent.



_________________________________________________________________
Join the world’s largest e-mail service with MSN Hotmail.
http://www.hotmail.com


--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/

Loading...