On Wednesday, June 28 at 08:05 PM, quoth Ingo van Lil:
>+ // a % b == a - floor(a/b) * b
>+ mpfr_div(output, first, second, GMP_RNDN);
>+ mpfr_floor(output, output);
>+ mpfr_mul(output, output, second, GMP_RNDN);
> mpfr_sub(output, first, output, GMP_RNDN);
Hmm. What is currently in CVS is this:
mpfr_set_ui(temp, 0, GMP_RNDN);
mpfr_div(temp, first, second, GMP_RNDN);
mpfr_rint(temp, temp, GMP_RNDZ);
mpfr_mul(output, temp, second, GMP_RNDN);
mpfr_sub(output, first, output, GMP_RNDN);
Although after reading about it, I'm not sure. So, the problem is how
to deal with negative numbers. For example, should -340 % 60 be -40 or
-20? The Math Forum
(http://mathforum.org/library/drmath/view/52343.html) seems to suggest
that both are essentially equally good answers.
Does anyone here have a preference?
~Kyle
--
Once again the conservative sandwich-heavy portfolio pays off for the
hungry investor!
-- Zoidberg