6 /* Test fp getround and fp setround */
12 newfunc("fpgetround/fpsetround");
15 test_iok(fpgetround(), FP_RN
);
18 test_iok(fpgetround(), FP_RM
);
21 test_iok(fpgetround(), FP_RP
);
24 test_iok(fpgetround(), FP_RZ
);
27 /* And fpset/fpgetmask */
31 newfunc("fpsetmask/fpgetmask");
34 test_iok(fpgetmask(),FP_X_INV
);
37 test_iok(fpgetmask(),FP_X_DX
);
40 test_iok(fpgetmask(),FP_X_OFL
);
43 test_iok(fpgetmask(),FP_X_UFL
);
46 test_iok(fpgetmask(),FP_X_IMP
);
52 newfunc("fpsetsticky/fpgetsticky");
54 fpsetsticky(FP_X_INV
);
55 test_iok(fpgetsticky(),FP_X_INV
);
58 test_iok(fpgetsticky(),FP_X_DX
);
60 fpsetsticky(FP_X_OFL
);
61 test_iok(fpgetsticky(),FP_X_OFL
);
63 fpsetsticky(FP_X_UFL
);
64 test_iok(fpgetsticky(),FP_X_UFL
);
66 fpsetsticky(FP_X_IMP
);
67 test_iok(fpgetsticky(),FP_X_IMP
);
71 test_getroundtoi (void)
73 newfunc("fpsetroundtoi/fpgetroundtoi");
75 fpsetroundtoi(FP_RDI_TOZ
);
76 test_iok(fpgetroundtoi(),FP_RDI_TOZ
);
79 fpsetroundtoi(FP_RDI_RD
);
80 test_iok(fpgetroundtoi(),FP_RDI_RD
);
89 __ieee_double_shape_type v
;
95 /* Lets see if changing the rounding alters the arithmetic.
96 Test by creating numbers which will have to be rounded when
97 added, and seeing what happens to them */
98 /* Keep them out here to stop the compiler from folding the results */
101 double add_rounded_up
;
102 double add_rounded_down
;
103 double sub_rounded_down
;
104 double sub_rounded_up
;
109 n
= dnumber(0x40000000, 0x00000008); /* near 2 */
110 m
= dnumber(0x40400000, 0x00000003); /* near 3.4 */
112 add_rounded_up
= dnumber(0x40410000, 0x00000004); /* For RN, RP */
113 add_rounded_down
= dnumber(0x40410000, 0x00000003); /* For RM, RZ */
114 sub_rounded_down
= dnumber(0xc0410000, 0x00000004); /* for RN, RM */
115 sub_rounded_up
= dnumber(0xc0410000, 0x00000003); /* for RP, RZ */
117 newfunc("fpsetround");
123 test_mok(r1
, add_rounded_up
, 64);
128 test_mok(r2
, add_rounded_down
, 64);
133 test_mok(r3
,add_rounded_up
, 64);
138 test_mok(r4
,add_rounded_down
,64);
144 test_mok(r1
,sub_rounded_down
,64);
149 test_mok(r2
,sub_rounded_down
,64);
155 test_mok(r3
,sub_rounded_up
,64);
160 test_mok(r4
,sub_rounded_up
,64);
167 fp_rnd old
= fpgetround();