NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

lib/44189: strtod(3) wrong results with "-0x"



>Number:         44189
>Category:       lib
>Synopsis:       strtod(3) wrong results with "-0x"
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Dec 03 13:05:01 +0000 2010
>Originator:     Nicolas Joly
>Release:        NetBSD 5.99.41
>Organization:
Institut Pasteur
>Environment:
System: NetBSD lanfeust.sis.pasteur.fr 5.99.41 NetBSD 5.99.41 (LANFEUST) #24: 
Fri Dec 3 12:01:14 CET 2010 
njoly%lanfeust.sis.pasteur.fr@localhost:/local/src/NetBSD/obj.amd64/sys/arch/amd64/compile/LANFEUST
 amd64
Architecture: x86_64
Machine: amd64
>Description:
strtod(3) give bad result when trying to parse "-0x" string

njoly@lanfeust [~]> cat strtod.c 
#include <err.h>
#include <stdlib.h>

int main() {
  char *p, *str;
  double d;

  str = "-0x";
  d = strtod(str, &p);
  warnx("%f >>%s<<", d, p);

  return 0; }
njoly@lanfeust [~]> make strtod
cc -O2   -o strtod strtod.c 
njoly@lanfeust [~]> ./strtod 
strtod: 0.000000 >>-0x<<

This looks wrong, and would have expected instead:

strtod: -0.000000 >>x<<

>How-To-Repeat:
Try the provided testcase.
>Fix:



Home | Main Index | Thread Index | Old Index