[comp.unix.questions] atof

tb@pemstgt.gtc.de (Tillmann Basien) (10/09/90)

Hy netlanders,
	I have SCO UNIX Version 3.2.0 with Development Kit.
	The atof()-function does not work proberly. Is there a work-a-round
	of this problem?

	My test-programm:

		#include <stdio.h>
		#include <math.h>

		main()
		{
		 double f;
		 f=atof("123.23");
		 printf("F: %f \n",f);
		}
-- 
Dipl.Ing. Tillmann Basien                Programmentwicklung fuer Microcomputer
Vaihinger Str.49, PostBox 810165		      +49-711-713047	FAX
7000 Stuttgart 80- West Germany                       +49-711-713045	PHONE

gwyn@smoke.BRL.MIL (Doug Gwyn) (10/11/90)

In article <1990Oct09.133730.478@pemstgt.gtc.de> tb@pemstgt.gtc.de (Tillmann Basien) writes:
>	The atof()-function does not work proberly.

I suspect that it works just fine.  Your sample program had a serious BUG.
(Hint: where was atof() declared?)

mju@mudos.ann-arbor.mi.us (Marc Unangst) (10/12/90)

gwyn@smoke.BRL.MIL (Doug Gwyn) writes:
> (Hint: where was atof() declared?)

In /usr/include/math.h.  Didn't you see the '#include <math.h>' line?

--
Marc Unangst               |
mju@mudos.ann-arbor.mi.us  | "Bus error: passengers dumped"
...!umich!leebai!mudos!mju | 

richard@aiai.ed.ac.uk (Richard Tobin) (10/12/90)

In article <1990Oct09.133730.478@pemstgt.gtc.de> tb@pemstgt.gtc.de (Tillmann Basien) writes:
>       The atof()-function does not work proberly. Is there a work-a-round
>       of this problem?

Unfortunately you don't say in what way it doesn't work.  One possibility
is that it is not declared in the .h files you include - try adding

   extern double atof();

to your program.

-- Richard
-- 
Richard Tobin,                       JANET: R.Tobin@uk.ac.ed             
AI Applications Institute,           ARPA:  R.Tobin%uk.ac.ed@nsfnet-relay.ac.uk
Edinburgh University.                UUCP:  ...!ukc!ed.ac.uk!R.Tobin

gwyn@smoke.BRL.MIL (Doug Gwyn) (10/13/90)

In article <gw5wq3w163w@mudos.ann-arbor.mi.us> mju@mudos.ann-arbor.mi.us (Marc Unangst) writes:
>gwyn@smoke.BRL.MIL (Doug Gwyn) writes:
>> (Hint: where was atof() declared?)
>In /usr/include/math.h.  Didn't you see the '#include <math.h>' line?

I certainly DID see that line.  I repeat the question.

rvdp@cs.vu.nl (=Ronald van der Pol) (10/13/90)

tb@pemstgt.gtc.de (Tillmann Basien) writes:

| Hy netlanders,
| 	I have SCO UNIX Version 3.2.0 with Development Kit.
| 	The atof()-function does not work proberly. Is there a work-a-round
| 	of this problem?
		atof() **does** work normally

| 	My test-programm:

| 		#include <stdio.h>
| 		#include <math.h>
			#include <stdlib.h>

| 		main()
| 		{
| 		 double f;
| 		 f=atof("123.23");
| 		 printf("F: %f \n",f);
| 		}
	SCO UNIX has an ANSI C compiler. ANSI C's atof() is decared
	in "stdlib.h".

--
		Ronald van der Pol  <rvdp@cs.vu.nl>

jmc@teqsoft.UUCP (Jack Cloninger) (10/14/90)

rvdp@cs.vu.nl (=Ronald van der Pol) writes:

>tb@pemstgt.gtc.de (Tillmann Basien) writes:

>| 	I have SCO UNIX Version 3.2.0 with Development Kit.
>| 	The atof()-function does not work proberly. Is there a work-a-round
>| 	of this problem?
>|
>	SCO UNIX has an ANSI C compiler. ANSI C's atof() is decared
>	in "stdlib.h".

IMHO the problem here is documentation.  The SCU Unix System V/386
Development System Programmer's Reference manual manual page for ATOF(S)
gives the following syntax description:

     #include <math.h>
     double atof(nptr)
     char *nptr;

The entry for "atoi" and "atol" give the correct include file, which
is as Mr. van der Pol states, "stdlib.h."  Mr. Basien did everything
correctly according to the manual, but was simply bitten by a
documentation error.
-- 
Jack Cloninger, TeqSoft, 112 US Highway 1, Tequesta, FL 33469    B-)
...uunet!comtst!teqsoft!jmc   Phone: 407-747-7163  Fax: 407-747-0354

george@hls0.hls.oz (George Turczynski) (10/17/90)

In article <14140@smoke.BRL.MIL>, gwyn@smoke.BRL.MIL (Doug Gwyn) writes:
> In article <gw5wq3w163w@mudos.ann-arbor.mi.us> mju@mudos.ann-arbor.mi.us (Marc Unangst) writes:
> >gwyn@smoke.BRL.MIL (Doug Gwyn) writes:
> >> (Hint: where was atof() declared?)
> >In /usr/include/math.h.  Didn't you see the '#include <math.h>' line?
> 
> I certainly DID see that line.  I repeat the question.

Try <floatingpoint.h>, included in <math.h> (SunOS 4.0.3).


-- 
George P. J. Turczynski,   Computer Systems Engineer. Highland Logic Pty Ltd.
ACSnet: george@highland.oz |^^^^^^^^^^^^^^^^^^^^^^^^| Suite 1, 348-354 Argyle St
Phone:  +61 48 683490      |  Witty remarks are as  | Moss Vale, NSW. 2577
Fax:    +61 48 683474      |  hard to come by as is | Australia.
---------------------------   space to put them !    ---------------------------

gwyn@smoke.BRL.MIL (Doug Gwyn) (10/19/90)

In article <945@hls0.hls.oz> george@hls0.hls.oz (George Turczynski) writes:
>Try <floatingpoint.h>, included in <math.h> (SunOS 4.0.3).

What does that have to do with the price of * in Ethiopia?