Ticket #19040: foo.c

File foo.c, 652 bytes (added by bhaible, 3 weeks ago)

test case foo.c

Line 
1#include <errno.h>
2#include <float.h>
3#include <math.h>
4#include <stdio.h>
5#include <stdlib.h>
6#include <string.h>
7#include <assert.h>
8
9/* Test gradual underflow, resulting in a denormalized number. */
10
11int main ()
12{
13#if LDBL_MAX_EXP > 10000
14 const char input[] = "1e-4950";
15#else
16 const char input[] = "1e-320";
17#endif
18 char *ptr;
19 long double result;
20 printf ("sizeof (long double) = %d\n", (int) sizeof (long double));
21 errno = 0;
22 result = strtold (input, &ptr);
23 assert (0.0L < result);
24 assert (result <= LDBL_MIN);
25 assert (ptr == input + strlen (input));
26#if !defined _MSC_VER
27 assert (errno == ERANGE);
28#endif
29 printf ("OK\n");
30}