diff options
author | Bruno Haible <bruno@clisp.org> | 2012-03-04 23:01:33 +0100 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2012-03-04 23:01:33 +0100 |
commit | 9655379852fdbf3a0797035fc30a4060a2b191cf (patch) | |
tree | c3f82f8a0a0e726c83e4706de7be12d09f6c5b44 /lib/remainderl.c | |
parent | 7feced3510dfaaeceba87eac4d5140977943e66d (diff) | |
download | gnulib-9655379852fdbf3a0797035fc30a4060a2b191cf.tar.gz |
remainder, remainderf, remainderl: Fix computation for large quotients.
* lib/remainder.c: Completely rewritten.
* lib/remainderf.c (remainderf): Use implementation of remainder.c with
USE_FLOAT.
* lib/remainderl.c (remainderl): Use implementation of remainder.c with
USE_LONG_DOUBLE.
* modules/remainder (Depends-on): Add isfinite, signbit, fabs, fmod,
isnand, isinf. Remove round, fma.
* modules/remainderf (Files): Add lib/remainder.c.
(Depends-on): Add isfinite, signbit, fabsf, fmodf, isnanf, isinf.
Remove roundf, fmaf.
* modules/remainderl (Files): Add lib/remainder.c.
(Depends-on): Add float, isfinite, signbit, fabsl, fmodl, isnanl,
isinf. Remove roundl, fmal.
* m4/remainder.m4 (gl_FUNC_REMAINDER): Update computation of
REMAINDER_LIBM.
* m4/remainderf.m4 (gl_FUNC_REMAINDERF): Update computation of
REMAINDERF_LIBM.
* m4/remainderl.m4 (gl_FUNC_REMAINDERL): Update computation of
REMAINDERL_LIBM.
Diffstat (limited to 'lib/remainderl.c')
-rw-r--r-- | lib/remainderl.c | 27 |
1 files changed, 2 insertions, 25 deletions
diff --git a/lib/remainderl.c b/lib/remainderl.c index 3476f948e2..474ebe217c 100644 --- a/lib/remainderl.c +++ b/lib/remainderl.c @@ -29,30 +29,7 @@ remainderl (long double x, long double y) #else -long double -remainderl (long double x, long double y) -{ - long double q = - roundl (x / y); - long double r = fmal (q, y, x); /* = x + q * y, computed in one step */ - /* Correct possible rounding errors in the quotient x / y. */ - long double half_y = 0.5L * y; - if (y >= 0) - { - /* Expect -y/2 <= r <= y/2. */ - if (r > half_y) - q -= 1, r = fmal (q, y, x); - else if (r < - half_y) - q += 1, r = fmal (q, y, x); - } - else - { - /* Expect y/2 <= r <= -y/2. */ - if (r > - half_y) - q += 1, r = fmal (q, y, x); - else if (r < half_y) - q -= 1, r = fmal (q, y, x); - } - return r; -} +# define USE_LONG_DOUBLE +# include "remainder.c" #endif |