On Friday, June 30 at 01:03 AM, quoth Ingo van Lil:
>Actually, if I'm reading the ADA reference manual correctly, the REM
>operator does exactly what your algorithm does (A REM B keeps the sign
>of A) while the MOD operator does the same as mine (A MOD B keeps the
>sign of B; I was mistaken when I claimed my algorithm would always pick
>the positive result).
Well, I'm not saying I'm in love with ADA, I'm just suggesting we
preserve the existing behavior for % and do a better/different one
with a new operator (called whatever we like).
>Proposed algorithm:
>
>mpfr_div(output, first, second, GMP_RNDN);
>if (MPFR_SIGN(first) >= 0)
>mpfr_floor(output, output);
>else
>mpfr_ceil(output, output);
>mpfr_mul(output, output, second, GMP_RNDN);
>mpfr_sub(output, first, output, GMP_RNDN);
Hmm, how is that different from mpfr_rint(output, output, GMP_RNDZ); ?
~Kyle
--
A wise man changes his mind, a fool never.
-- Spanish proverb