strtod vs NAN?

Larry Rosenman ler at lerctr.org
Thu May 13 19:14:29 PDT 2004


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="NAN";
  char *border1="/////////////////////////////";
  char *input2="inf";
  char *border2="/////////////////////////////";
  char **ptr;

  num=strtod(input,ptr);
  printf("num=%g\n",num);
  printf("errno=%ld\n",errno);
  printf("ptr=%p, points to %s\n",*ptr,*ptr);
  num=strtod(input2,ptr);
  printf("num=%g\n",num);
  printf("errno=%ld\n",errno);
  printf("ptr=%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 
1 23:09:13 CDT 2004 
ler at lerlaptop.lerctr.org:/usr/obj/usr/src/sys/LERLAPTOP  i386
$
-- 
Larry Rosenman                     http://www.lerctr.org/~ler
Phone: +1 972-414-9812                 E-Mail: ler at lerctr.org
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-current/attachments/20040513/d3c04e72/attachment.bin


More information about the freebsd-current mailing list