diff options
Diffstat (limited to 'numeric.c')
-rw-r--r-- | numeric.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -5978,7 +5978,11 @@ prefix##_isqrt(argtype n) \ while ((t = n/x) < (argtype)x) x = (rettype)((x + t) >> 1); \ return x; \ } \ - return (rettype)sqrt(argtype##_TO_DOUBLE(n)); \ + rettype x = (rettype)sqrt(argtype##_TO_DOUBLE(n)); \ + /* libm sqrt may returns a larger approximation than actual. */ \ + /* Our isqrt always returns a smaller approximation. */ \ + if (x * x > n) x--; \ + return x; \ } #if SIZEOF_LONG*CHAR_BIT > DBL_MANT_DIG |