Article View: gnu.gcc.help
Article #42324Bug in gcc, libc, or programmer?
From: taavo r
Date: Tue, 12 Dec 1995 00:00
Date: Tue, 12 Dec 1995 00:00
30 lines
1135 bytes
1135 bytes
What is wrong with this piece of code?. The strtod()
was breaking a program I had, but atof seems to work...
#include <stdlib.h>
#include <stdio.h>
int main()
{
double dPi, dZero, dPi2;
char szPi[]="3.14";
dPi = strtod ( szPi, NULL);
dPi2 = atof (szPi);
dZero = dPi - dPi2;
printf ("\nPi: %f Pi2: %f Zero: %f", dPi, dPi2, dZero);
return 1;
}
when compiled and run on a gcc 263, SunOS 4.1.3, here
is the (screwed up) output:
$a.out
$Pi: -134218664.000000 Pi2: 3.140000 Zero: -134218
but it works flawlessly on gcc 272 on a linux.
Is it a bugf in my program , in libc, or in gcc?
thankd for the help, taavo r.
Technical Details
Message-ID:
<30CE026D.380E7120@taavo1.roc.servtech.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,b762babb78f8c3a3,start
X-Google-Attributes: gid11318c,public
From: taavo r <taavo@taavo1.roc.servtech.com>
Subject: Bug in gcc, libc, or programmer?
Date: 1995/12/12
Message-ID: <30CE026D.380E7120@taavo1.roc.servtech.com>
X-Deja-AN: 121609994
content-type: text/plain; charset=us-ascii
organization: {:->-}
mime-version: 1.0
newsgroups: gnu.gcc.help
x-mailer: Mozilla 2.0b3 (X11; I; Linux 1.2.13 i486)