fix scalbn when result is in the subnormal range
commit8c44a060243f04283ca68dad199aab90336141db
authorSzabolcs Nagy <nsz@port70.net>
Mon, 3 Apr 2017 00:38:13 +0000 (3 02:38 +0200)
committerRich Felker <dalias@aerifal.cx>
Fri, 21 Apr 2017 21:31:00 +0000 (21 17:31 -0400)
tree5fd8fd700ac059c1ef2f2999c5783207c91bcf59
parent2577b1bc16124d0690b9dd268a9f582f80bdcd67
fix scalbn when result is in the subnormal range

in nearest rounding mode scalbn could introduce double rounding error
when an intermediate value and the final result were both in the
subnormal range e.g.

  scalbn(0x1.7ffffffffffffp-1, -1073)

returned 0x1p-1073 instead of 0x1p-1074, because the intermediate
computation got rounded to 0x1.8p-1023.

with the fix an intermediate value can only be in the subnormal range
if the final result is 0 which is correct even after double rounding.
(there still can be two roundings so signals may be raised twice, but
that's only observable with trapping exceptions which is not supported.)
src/math/scalbn.c
src/math/scalbnf.c
src/math/scalbnl.c