#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, x1; 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_init2( x1, SIZE * BITS_PER_MP_LIMB); #if 0 mpf_set_ui( x1, 1); mpf_mul( x1, x, x1); #else mpf_mul_ui( x1, x, 1); #endif r = mpf_cmp( x, x1); printf("cmp (x, 1*x) == %d\n", r); return 0; }