[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GMP ceil/floor/trunc & round-offs
From: |
Kevin Ryde |
Subject: |
Re: GMP ceil/floor/trunc & round-offs |
Date: |
03 May 2001 11:09:25 +1000 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) Emacs/20.5 |
Hans Aberg <address@hidden> writes:
>
> (floating, precision) -> floating
> where the precision argument specoifies the precision of the function
> return.
mpf_set_prec does that, more or less. Or mpf_set, since it uses the
precision of its target when copying. I'd doubt the value of having a
specific rounding direction (ceil/floor/trunc), since all the other
mpf functions understand only trunc (as it happens). Exact rounding
is left to mpfr.
> Note that there are special round-off techniques favoured by some,
> like that the number exactly in the middle in the round-off process is
> rounded up/down depending on what the next higher binary digit is. (I am
> myself somewhat sceptical about those round-off techniques, and I merely
> note that they do exist.)
Yes, round to even or whatever it's called. That'd be an idea for
mpfr if anyone's keen.
> int_ceil, int_floor, int_trunc: rational -> integer
mpz_set_q does the trunc version. A direct call to mpz_fdiv_q or
mpz_cdiv_q can be used for the others.
> frac_ceil, frac_floor, frac_trunc: rational -> rational
I guess that'd be mpq_ceil etc. That sort of thing is among the many
operations not directly provided for mpq. Use of mpq_numref and
mpq_denref is recommended.
- Re: GMP ceil/floor/trunc & round-offs,
Kevin Ryde <=