Lines Matching +full:double +full:- +full:precision
1 /*-
28 * Test that floating-point arithmetic works as specified by the C standard.
51 static const double one_d = 1.0 + DBL_EPSILON / 2;
52 static const long double one_ld = 1.0L + LDBL_EPSILON / 2;
61 printf("%sok %d - %s%s\n", pass || skip ? "" : "not ", testnum, in test1()
68 * Compare d1 and d2 using special rules: NaN == NaN and +0 != -0.
71 fpequal(long double d1, long double d2) in fpequal()
80 run_zero_opt_test(double d1, double d2) in run_zero_opt_test()
84 fpequal(d1 - d2, 0.0) in run_zero_opt_test()
85 && fpequal(-d1 + 0.0, 0.0) in run_zero_opt_test()
86 && fpequal(-d1 - d2, -0.0) in run_zero_opt_test()
87 && fpequal(-(d1 - d2), -0.0) in run_zero_opt_test()
88 && fpequal(-d1 - (-d2), 0.0)); in run_zero_opt_test()
92 run_inf_opt_test(double d) in run_inf_opt_test()
99 static inline double
100 todouble(long double ld) in todouble()
107 tofloat(double d) in tofloat()
116 volatile long double vld; in run_tests()
117 long double ld; in run_tests()
118 volatile double vd; in run_tests()
119 double d; in run_tests()
124 test("sign bits", fpequal(-0.0, -0.0) && !fpequal(0.0, -0.0)); in run_tests()
147 /* XXX disabled (works with -O0); gcc doesn't support FENV_ACCESS */ in run_tests()
148 skiptest("FENV_ACCESS: Inf->int conversion raises invalid exception", in run_tests()
151 /* Raising an inexact exception here is an IEEE-854 requirement. */ in run_tests()
155 test("0.75->int conversion rounds toward 0, raises inexact exception", in run_tests()
159 vd = -42.0; in run_tests()
161 test("-42.0->int conversion is exact, raises no exception", in run_tests()
162 x == -42 && fetestexcept(ALL_STD_EXCEPT) == 0); in run_tests()
167 skiptest("FENV_ACCESS: const Inf->int conversion raises invalid", in run_tests()
173 skiptest("FENV_ACCESS: const double->int conversion raises inexact", in run_tests()
176 test("compile-time constants don't have too much precision", in run_tests()
179 test("const minimum rounding precision", in run_tests()
188 test("runtime minimum rounding precision", in run_tests()
191 test("explicit float to float conversion discards extra precision", in run_tests()
194 test("explicit double to float conversion discards extra precision", in run_tests()
197 test("explicit ldouble to float conversion discards extra precision", in run_tests()
201 test("explicit double to double conversion discards extra precision", in run_tests()
202 (double)(1.0 + DBL_EPSILON * 0.5) == 1.0 && in run_tests()
203 (double)(1.0 + vd * 0.5) == 1.0); in run_tests()
204 test("explicit ldouble to double conversion discards extra precision", in run_tests()
205 (double)(1.0L + DBL_EPSILON * 0.5L) == 1.0 && in run_tests()
206 (double)(1.0L + vd * 0.5L) == 1.0); in run_tests()
210 * evaluated in double precision or higher, but some compilers get in run_tests()
214 test("implicit promption to double or higher precision is consistent", in run_tests()
226 test("const assignment discards extra precision", f == 1.0F && d == 1.0); in run_tests()
230 test("variable assignment discards explicit extra precision", in run_tests()
234 test("variable assignment discards implicit extra precision", in run_tests()
237 test("return discards extra precision", in run_tests()
242 /* XXX disabled (works with -frounding-math) */ in run_tests()