Kyle Wheeler <kyle-wcalc-yahoo@...> schrieb:
>> 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); ?
Well, rounding output towards zero would pick floor() or ceil()
depending on the sign of output. I'm checking the sign of the first
operand instead. So, if first and output have the same sign (i.e. if
second is positive) both algorithms are equal. If first and output have
opposite signs (i.e. second is negative) I'm doing the opposite (i.e.
rounding away from zero).
Cheers,
Ingo