diff options
Diffstat (limited to 'src/math/scalbn.c')
-rw-r--r-- | src/math/scalbn.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/math/scalbn.c b/src/math/scalbn.c index 530e07c7..182f5610 100644 --- a/src/math/scalbn.c +++ b/src/math/scalbn.c @@ -16,11 +16,13 @@ double scalbn(double x, int n) n = 1023; } } else if (n < -1022) { - y *= 0x1p-1022; - n += 1022; + /* make sure final n < -53 to avoid double + rounding in the subnormal range */ + y *= 0x1p-1022 * 0x1p53; + n += 1022 - 53; if (n < -1022) { - y *= 0x1p-1022; - n += 1022; + y *= 0x1p-1022 * 0x1p53; + n += 1022 - 53; if (n < -1022) n = -1022; } |