1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <stdint.h>
4 #include <errno.h>
5
main(int argc,char * argv[])6 int main(int argc, char *argv[])
7 {
8 int i;
9 union {float f; uint32_t i;} f;
10 union {double f; uint64_t i;} d;
11 union {long double f; struct {uint64_t m; uint16_t se;} i;} ld;
12 char *eptr;
13
14 for (i = 1; i < argc; i++) {
15 errno = 0;
16 f.f = strtof(argv[i], &eptr);
17 printf("0x%08x (*eptr:%d errno:%d)\n", f.i, *eptr, errno);
18 errno = 0;
19 d.f = strtod(argv[i], &eptr);
20 printf("0x%08x %08x (*eptr:%d errno:%d)\n",
21 (unsigned)(d.i>>32), (unsigned)d.i, *eptr, errno);
22 errno = 0;
23 ld.f = strtold(argv[i], &eptr);
24 printf("0x%04x %08x %08x (*eptr:%d errno:%d)\n",
25 ld.i.se, (unsigned)(ld.i.m>>32), (unsigned)ld.i.m, *eptr, errno);
26 }
27 return 0;
28 }
29