#include #include #if 0 # include "gmp-impl.h" /* needs config.h */ #else # define BITS_PER_MP_LIMB (sizeof(long) * 8) #endif #define SIZE 16 int main(void) { mpf_t x, one; int r; mpf_init2( x, SIZE * BITS_PER_MP_LIMB); mpf_set_si( x, -1); mpf_div_2exp( x, x, (SIZE + 1) * BITS_PER_MP_LIMB); /* x == -0x0.000...001. */ mpf_add_ui( x, x, 2); /* x == 0x1.fff...fff. */ mpf_div( x, x, x); r = mpf_cmp_ui( x, 1); printf("cmp (x/x, 1) == %d\n", r); }