64-bit integer conversion support

Décio Luiz Gazzoni Filho decio at decpp.net
Thu Apr 26 20:47:52 CEST 2007


Le Apr 26, 2007 à 8:19 AM, Arseny Kapoulkine a écrit :

> Hello,
>
> 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?

If performance is not critical, why not do an mpz_get_ui(), a shift  
by 32, then another mpz_get_ui(), and concatenate these two?

Décio



More information about the gmp-discuss mailing list