Rounding error in (**)/2

Almost. There are a couple of additional patches to mpq_to_double; one to avoid over-rounding in the FE_UPWARD and FE_DOWNWARD rounding modes, and one to ensure that infinity is returned the result will overflow a 64 bit float.

The new function is named mpz_float which is called from mpz_to_double rather than mpz_fdiv with a divisor argument of MPZ_ONE.

Changes are confined to gmp.c as described and Tests/rational/test_ieee_754.pl which will have some additional rounding tests cases for floating various “types” of integers.

1 Like