diff options
Diffstat (limited to 'src/regress/lib/libc/ieeefp/round/round.c')
-rw-r--r-- | src/regress/lib/libc/ieeefp/round/round.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/regress/lib/libc/ieeefp/round/round.c b/src/regress/lib/libc/ieeefp/round/round.c new file mode 100644 index 0000000000..b9fcd9771e --- /dev/null +++ b/src/regress/lib/libc/ieeefp/round/round.c | |||
@@ -0,0 +1,44 @@ | |||
1 | /* $NetBSD: round.c,v 1.1 1995/04/26 00:27:28 jtc Exp $ */ | ||
2 | |||
3 | /* | ||
4 | * Written by J.T. Conklin, Apr 18, 1995 | ||
5 | * Public domain. | ||
6 | */ | ||
7 | |||
8 | #include <assert.h> | ||
9 | #include <stdlib.h> | ||
10 | #include <ieeefp.h> | ||
11 | #include <float.h> | ||
12 | |||
13 | int | ||
14 | main() | ||
15 | { | ||
16 | /* | ||
17 | * This test would be better if it actually performed some | ||
18 | * calculations to verify the selected rounding mode. But | ||
19 | * this is probably acceptable since the fp{get,set}round | ||
20 | * functions usually just get or set the processors fpu | ||
21 | * control word. | ||
22 | */ | ||
23 | |||
24 | assert(fpgetround() == FP_RN); | ||
25 | assert(FLT_ROUNDS == 1); | ||
26 | |||
27 | assert(fpsetround(FP_RP) == FP_RN); | ||
28 | assert(fpgetround() == FP_RP); | ||
29 | assert(FLT_ROUNDS == 2); | ||
30 | |||
31 | assert(fpsetround(FP_RM) == FP_RP); | ||
32 | assert(fpgetround() == FP_RM); | ||
33 | assert(FLT_ROUNDS == 3); | ||
34 | |||
35 | assert(fpsetround(FP_RZ) == FP_RM); | ||
36 | assert(fpgetround() == FP_RZ); | ||
37 | assert(FLT_ROUNDS == 0); | ||
38 | |||
39 | assert(fpsetround(FP_RN) == FP_RZ); | ||
40 | assert(fpgetround() == FP_RN); | ||
41 | assert(FLT_ROUNDS == 1); | ||
42 | |||
43 | exit(0); | ||
44 | } | ||