64-bit integer conversion support

Richard B. Kreckel kreckel at ginac.de
Thu Apr 26 22:22:11 CEST 2007


Arseny Kapoulkine wrote:
> I am developing a bigint library, which will have GMP as one of it's
> implementation. I'd like to provide functions for converting between 64-bit
> integer (both signed and unsigned) and bigint. The problem is that GMP's
> integer conversion functions do not seem to support 64-bit integers (that
> is, when long type is not 64-bit).
> 
> I can do something similar to what mpz_get_si does, only use more limbs if
> needed, but this approach depends on GMP internal representation, which I
> don't quite like.
> Also there are import/export functions, but as I understand they are for
> different purpose - it's just binary serialization, not conversion to
> natively supported type.
> 
> So, the question is - what are the available options if I want to achieve
> maximum portability, and performance is not critical here?

Straightforward implementation for limb sizes (called intDsize) of 8, 
16, 32, or 64 bits to and from 64 bit buitin type:
<http://www.ginac.de/viewcvs/cln/src/integer/conv/cl_I_from_Q.cc?view=co>
<http://www.ginac.de/viewcvs/cln/src/integer/conv/cl_I_to_Q.cc?view=co>
(Needs some supporting functions available at the same place.)

  -richy.
-- 
Richard B. Kreckel
<http://www.ginac.de/~kreckel/>


More information about the gmp-discuss mailing list