Xref: utzoo comp.lang.c:38387 comp.unix.aix:4602 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!olivea!samsung!usc!rpi!fitz From: fitz@mml0.meche.rpi.edu (Brian Fitzgerald) Newsgroups: comp.lang.c,comp.unix.aix Subject: strtod() problem - bug in library? Summary: convert "0" ? Message-ID: <5!mgj6f@rpi.edu> Date: 18 Apr 91 00:51:48 GMT Organization: Rensselaer Polytechnic Institute, Troy NY Lines: 70 Nntp-Posting-Host: mml0.meche.rpi.edu String-to-decimal conversion problem on AIX/370 ------ -- ------- ---------- ------- -- ------- When a string equivalent to zero containing no decimal point is encountered, strtod() does not store a pointer to the unconverted suffix. Instead, it stores the same pointer that was supplied, as though the conversion were unsuccessful. The AIX strtod() man page says that the decimal point is optional. Is my strtod function broken, is my code wrong, or am I trying to do something non-portable or undefined? If IBM has a bug fix, and you know the bug id number, or if you have heard of this before, please send me e-mail or post to this newsgroup. Thanks in advance. Brian /* tsd.c test string-to-decimal */ #include int main () { char *s = "3.141593 1 -1 0.0 0 2.718282"; char *s1; int i; double d; double strtod(); s1=s; for(i=0;;i++) { d = strtod(s, &s1); if (s == s1) break; (void) printf("i %i d %f\n", i , d); s = s1; } return 0; } IBM 3090 Mainframe running AIX/370 % make tsd cc -O tsd.c -o tsd MetaWare High C Compiler R2.1r (c) Copyright 1987-89, MetaWare Incorporated % tsd i 0 d 3.141593 i 1 d 1.000000 i 2 d -1.000000 i 3 d 0.000000 <-- why no more output? Sparc IPC running SunOS 4.1.1 % make tsd cc -target sun4 -o tsd tsd.c % tsd i 0 d 3.141593 i 1 d 1.000000 i 2 d -1.000000 i 3 d 0.000000 i 4 d 0.000000 i 5 d 2.718282 -- We need to secure as many banks in our computer banks as possible. We don't want no one else's help, but yours. Miller's Comsumer Service