Out of curiosity, why use hashing when you can sort by value? Comparison is very quick, as it compares the bytes / limbs from MSB to LSB, returning a result as soon as they differ.
You can access the raw data using the platform-dependent mp_limb_t
type. Both mpz_t
and mpf_t
have an mp_limb_t
vector stored at the address specified by _mp_d
, with the number of significant limbs given by the absolute value of the _mp_size
field. (the definitions are in gmp.h
)
Of course, if the hash function depends on an 8-bit byte vector, you will need to convert the limb vector. Fortunately, the number of bits in a mp_limb_t
- GMP_LIMB_BITS
- is always going to be divisible by 8 on any sane platform.