Date: Thu, 13 May 2004 22:23:31 -0400 From: Stephan Uphoff <ups@tree.com> To: Larry Rosenman <ler@lerctr.org> Cc: freebsd-current@freebsd.org Subject: Re: strtod vs NAN? Message-ID: <200405140223.i4E2NV9F006242@palm.tree.com> In-Reply-To: Message from Larry Rosenman <ler@lerctr.org> <9AE9B859FD197218F21D81D0@lerlaptop.lerctr.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Try: char *ptr; and num=strtod(input,&ptr); Larry Rosenman wrote: > > Isn't strtod supposed to deal with NAN's? > > I ran: > > $ cat test3.c > #include <stdlib.h> > #include <stdio.h> > #include <errno.h> > int main(int argc,char **argv) > { > double num; > char *input=3D"NAN"; > char *border1=3D"/////////////////////////////"; > char *input2=3D"inf"; > char *border2=3D"/////////////////////////////"; > char **ptr; > > num=3Dstrtod(input,ptr); > printf("num=3D%g\n",num); > printf("errno=3D%ld\n",errno); > printf("ptr=3D%p, points to %s\n",*ptr,*ptr); > num=3Dstrtod(input2,ptr); > printf("num=3D%g\n",num); > printf("errno=3D%ld\n",errno); > printf("ptr=3D%p, points to %s\n",*ptr,*ptr); > exit(0); > } > $ > > and I get a SIGSEGV in the first strtod call. > > the manpage for strtod implies, to me, that it should deal with it. > > Thanks! > > This is with -CURRENT as of: > > $ uname -a > FreeBSD lerlaptop.lerctr.org 5.2-CURRENT FreeBSD 5.2-CURRENT #111: Sat May=20 > 1 23:09:13 CDT 2004=20 > ler@lerlaptop.lerctr.org:/usr/obj/usr/src/sys/LERLAPTOP i386 > $ > --=20 > Larry Rosenman http://www.lerctr.org/~ler > Phone: +1 972-414-9812 E-Mail: ler@lerctr.org > US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749 >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200405140223.i4E2NV9F006242>