17 mpfr_set_ui(a,53, mpfr_rnd_t::MPFR_RNDN);
22 mpfr_set_prec(b, mpfr_get_prec(a));
23 mpfr_set(b, a, MPFR_RNDN);
25 assert(b->_mpfr_prec == a->_mpfr_prec);
26 assert(b->_mpfr_sign = a->_mpfr_sign);
27 assert(b->_mpfr_exp = a->_mpfr_exp);
29 std::size_t limbs = (std::size_t)
std::ceil(
double(a->_mpfr_prec)/double(mp_bits_per_limb));
31 assert(b->_mpfr_d[limbs-1] == a->_mpfr_d[limbs-1]);
37 void to_int(mpz_t intRep, mpfr_t a) {
38 std::cout <<
"Bits per limb " << mp_bits_per_limb << std::endl;
39 std::cout <<
"Number limbs " <<
std::ceil(
double(a->_mpfr_prec)/
double(mp_bits_per_limb)) << std::endl;
40 std::cout <<
"Precision is " << a->_mpfr_prec << std::endl;
41 std::cout <<
"Sign is " << a->_mpfr_sign << std::endl;
43 std::cout <<
"Exponent is " << a->_mpfr_exp << std::endl;
44 std::cout <<
"Min Exponent is " << mpfr_get_emin() << std::endl;
46 std::cout <<
"Scaled exponent: " << (a->_mpfr_exp +
std::abs(mpfr_get_emin())) << std::endl;
50 int limbs =
std::ceil(
double(a->_mpfr_prec)/
double(mp_bits_per_limb));
67 unsigned offset = mp_bits_per_limb - (a->_mpfr_prec % mp_bits_per_limb);
74 mpz_set_ui(tmp, a->_mpfr_d[limbs-1]);
76 mpz_mul_2exp(tmp, tmp, (mp_bits_per_limb*(limbs-1)));
77 mpz_add(mant, mant, tmp);
81 mpz_cdiv_q_2exp(mant, mant, offset);
83 mpz_get_str(outStr, 2,mant);
84 std::cout <<
"Mantissa: " << std::string(outStr) << std::endl;
86 unsigned correction = (a->_mpfr_exp - a->_mpfr_prec);
88 std::cout <<
"correction: " << correction << std::endl;
90 mpz_mul_2exp(mant, mant, correction);
106 int main (
int argc,
char** argv)
127 #ifdef USE_MPFR_FLOAT
int main(int argc, char **argv)
Interval< Number > ceil(const Interval< Number > &_in)
Method which returns the next larger integer of the passed number or the number itself,...
Interval< Number > abs(const Interval< Number > &_in)
Method which returns the absolute value of the passed number.
signed compare(const BasicConstraint< Pol > &_constraintA, const BasicConstraint< Pol > &_constraintB)
Compares _constraintA with _constraintB.
Integer to_int(const Interval< Number > &_floatInterval)
Casts the Interval to an arbitrary integer type which has a constructor for a native int.