two questions on GMP & C float
Marc Glisse
marc.glisse at normalesup.org
Sat May 16 17:53:00 CEST 2009
On Sat, 16 May 2009, Sylvain Pion wrote:
>> That is quite a different issue though. These 0s are useful.
>
> I think it's the only issue here. Maybe I was just reading between the
> lines of the OP's mail, because I know the issue.
I read his question as asking whether .5 would give the mpq 1/2 or
possibly 2^52/2^53, but I may have misunderstood.
Not quite related: a function to find the smallest fraction in some float
interval could be useful, but I am not sure where it would fit best (gmp
tries to handle float and double as little as possible, mpfi is more about
conversions that widen an interval, etc).
> Modular arithmetic here is cool, but it tends to be trickier to put
> in place due to its constraints.
Indeed, predicates don't usually look like a polynomial to evaluate, even
when it basically amounts to that in the end. Still, this would be
interesting to try some day.
> An mpz_t multiplied by a power of 2 is nothing else than an mpfr_t
> (apart from the inf/nan refinements) in terms of representable values.
> This is my point.
Compared to (mpz,int) (and mpf), I think mpfr has alloc==size (this could
be changed in a compatible way (except for a couple macros that expose too
much internals), or allocated storage could be truncated (if
mpfr_free_func ignores size), so I may be mistaken), which makes a lot of
sense for fixed precision arithmetic, but may be a bit less convenient
here (I don't really know, it may not matter so much).
> Do you suggest to add a third one in yet another separate library,
> to deal with the operations in question (after all, inf/nan is not
> needed there, and my operations are way different from mpf_t's since
> they are exact, so "it does not fit"...)?
(inf and nan still make sense, even if I don't know whether we would need
them)
> Or do you suggest a "toy library"
> re-using mpfr_t but not integrated in MPFR, so that it's going
> to cost much more in terms of packaging&such as it is to maintain
> it as part of MPFR?
I was mostly considering a new type, but I can see your points.
--
Marc Glisse
More information about the gmp-discuss
mailing list