6 /* Test fp getround and fp setround */
9 _DEFUN_VOID(test_getround
)
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 */
29 _DEFUN_VOID(test_getmask
)
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
);
50 _DEFUN_VOID(test_getsticky
)
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 _DEFUN_VOID(test_getroundtoi
)
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
);
85 _DEFUN(dnumber
,(msw
, lsw
),
90 __ieee_double_shape_type v
;
96 /* Lets see if changing the rounding alters the arithmetic.
97 Test by creating numbers which will have to be rounded when
98 added, and seeing what happens to them */
99 /* Keep them out here to stop the compiler from folding the results */
102 double add_rounded_up
;
103 double add_rounded_down
;
104 double sub_rounded_down
;
105 double sub_rounded_up
;
108 _DEFUN_VOID(test_round
)
110 n
= dnumber(0x40000000, 0x00000008); /* near 2 */
111 m
= dnumber(0x40400000, 0x00000003); /* near 3.4 */
113 add_rounded_up
= dnumber(0x40410000, 0x00000004); /* For RN, RP */
114 add_rounded_down
= dnumber(0x40410000, 0x00000003); /* For RM, RZ */
115 sub_rounded_down
= dnumber(0xc0410000, 0x00000004); /* for RN, RM */
116 sub_rounded_up
= dnumber(0xc0410000, 0x00000003); /* for RP, RZ */
118 newfunc("fpsetround");
124 test_mok(r1
, add_rounded_up
, 64);
129 test_mok(r2
, add_rounded_down
, 64);
134 test_mok(r3
,add_rounded_up
, 64);
139 test_mok(r4
,add_rounded_down
,64);
145 test_mok(r1
,sub_rounded_down
,64);
150 test_mok(r2
,sub_rounded_down
,64);
156 test_mok(r3
,sub_rounded_up
,64);
161 test_mok(r4
,sub_rounded_up
,64);
166 _DEFUN_VOID(test_ieee
)
168 fp_rnd old
= fpgetround();