Skip to content

Instantly share code, notes, and snippets.

@shirosaki
Created September 18, 2012 07:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shirosaki/3741901 to your computer and use it in GitHub Desktop.
Save shirosaki/3741901 to your computer and use it in GitHub Desktop.
test strtod
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
int main() {
char n[] = "0.1E-321";
double x;
x = strtod(n, 0);
printf("n = %s\nd = %0.330f\nerrno = %d\n", n, x, errno);
}

gcc version 4.7.1 (tdm-1) on XP

$ ./a.exe
n = 0.1E-321
d = 0.00000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000
errno = 34

gcc version 4.7.1 (rubenvb-4.7.1) on XP

$ ./a.exe
n = 0.1E-321
d = 0.00000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000098813129
errno = 34

VC 2010 on XP

Microsoft(R) 32-bit C/C++ Optimizing Compiler Version 16.00.40219.01 for 80x86

$ strtod.exe
n = 0.1E-321
d = 0.00000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000098813129
errno = 0

gcc version 4.1.2 20080704 (Red Hat 4.1.2-44) on Linux

$ ./a.out
n = 0.1E-321
d = 0.00000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000098813129
errno = 0
@jonforums
Copy link

odd, here's what I get using a couple of our 32bit DevKit's:

gcc 4.6.2 (mingw-32-4.6.2) on Win7 32 bit

n = 0.1E-321
d = 0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000098813129
errno = 0

gcc 4.7.1 (tdm-32-4.7.1) on Win7 32bit

n = 0.1E-321
d = 0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000098813129
errno = 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment