mpn_sqrtrem{1,2} - rounding mode

Adrien Prost-Boucle adrien.prost-boucle at
Sat Mar 25 19:20:51 UTC 2017


> Let N = 2147580932 = 46342^2 - 1, and rounding be toward +infinity.
> Will N be rounded up to 8388989*256 when converted to float?
> Then its root 11863552.60.../256 rounded up to 11863553/256?
> and this number converted back to integer rounding it up to 46343?
> If so, we have a possible +2.

To the best of my knowledge, rounding does not apply when converting to
integer, where only the integer part is taken, and no rounding toward
nothing. So I don't think this is a +2 case.

Anyway, I launched exhaustive tests again on both 32b and 64b versions,
with all 4 rnd modes, and all works with the +/-1 correction.
(reminder: I just the tested root result of all N*N and N*N-1 values)


More information about the gmp-devel mailing list