
On 2009-01-30 18:41:51 +0100, Paul Zimmermann wrote:
an alternate trick is to store in the mpz_t *pointer* a value of the form p=2k+1, where k is a small integer. Since pointers are usually even, you can easily distinguish between small integers and GMP integers, and you obtain the value k = p >> 1. It is also more memory-efficient since you don't allocate the mpz_t structure. A famous computer algebra system is using that trick together with GMP.
Conversion between pointers and integers is implementation-defined. You need to make sure that pointers to integers are really even. On the ARM in 26-bit mode, the least 2 significant bits of the PC have a special meaning, and I'm not sure that a pointer to an integer is necessarily even (it may be difficult to know what happens after optimization).