Last change
on this file was 2036, checked in by bird, 20 years ago |
Initial revision
|
-
Property cvs2svn:cvs-rev
set to
1.1
-
Property svn:eol-style
set to
native
-
Property svn:executable
set to
*
-
Property svn:keywords
set to
Author Date Id Revision
|
File size:
1.3 KB
|
Line | |
---|
1 | #include <fenv.h>
|
---|
2 | #include <math.h>
|
---|
3 | #include <float.h>
|
---|
4 | #include <stdlib.h>
|
---|
5 | #include <stdio.h>
|
---|
6 |
|
---|
7 | int
|
---|
8 | main (void)
|
---|
9 | {
|
---|
10 | int result = 0;
|
---|
11 |
|
---|
12 | long double tl = (long double) FLT_MAX + 0x1.0p128L;
|
---|
13 | float fi = INFINITY;
|
---|
14 | float m = FLT_MAX;
|
---|
15 | feclearexcept (FE_ALL_EXCEPT);
|
---|
16 | if (nexttowardf (m, tl) != fi)
|
---|
17 | {
|
---|
18 | puts ("nexttowardf+ failed");
|
---|
19 | ++result;
|
---|
20 | }
|
---|
21 | if (fetestexcept (FE_OVERFLOW) == 0)
|
---|
22 | {
|
---|
23 | puts ("nexttowardf+ did not overflow");
|
---|
24 | ++result;
|
---|
25 | }
|
---|
26 | feclearexcept (FE_ALL_EXCEPT);
|
---|
27 | if (nexttowardf (-m, -tl) != -fi)
|
---|
28 | {
|
---|
29 | puts ("nexttowardf- failed");
|
---|
30 | ++result;
|
---|
31 | }
|
---|
32 | if (fetestexcept (FE_OVERFLOW) == 0)
|
---|
33 | {
|
---|
34 | puts ("nexttowardf- did not overflow");
|
---|
35 | ++result;
|
---|
36 | }
|
---|
37 |
|
---|
38 | tl = (long double) DBL_MAX + 1.0e305L;
|
---|
39 | double di = INFINITY;
|
---|
40 | double dm = DBL_MAX;
|
---|
41 | feclearexcept (FE_ALL_EXCEPT);
|
---|
42 | if (nexttoward (dm, tl) != di)
|
---|
43 | {
|
---|
44 | puts ("nexttoward+ failed");
|
---|
45 | ++result;
|
---|
46 | }
|
---|
47 | if (fetestexcept (FE_OVERFLOW) == 0)
|
---|
48 | {
|
---|
49 | puts ("nexttoward+ did not overflow");
|
---|
50 | ++result;
|
---|
51 | }
|
---|
52 | feclearexcept (FE_ALL_EXCEPT);
|
---|
53 | if (nexttoward (-dm, -tl) != -di)
|
---|
54 | {
|
---|
55 | puts ("nexttoward- failed");
|
---|
56 | ++result;
|
---|
57 | }
|
---|
58 | if (fetestexcept (FE_OVERFLOW) == 0)
|
---|
59 | {
|
---|
60 | puts ("nexttoward- did not overflow");
|
---|
61 | ++result;
|
---|
62 | }
|
---|
63 |
|
---|
64 | return result;
|
---|
65 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.