[PATCH] Fix powf overflow handling in non-nearest rounding mode [BZ #23961]

Szabolcs Nagy Szabolcs.Nagy@arm.com
Mon Dec 10 15:09:00 GMT 2018


The threshold value at which powf overflows depends on the rounding mode
and the current check did not take this into account. So when the result
was rounded away from zero it could become infinity without setting
errno to ERANGE.

Example: pow(0x1.7ac7cp+5, 23) is 0x1.fffffep+127 + 0.1633ulp

If the result goes above 0x1.fffffep+127 + 0.5ulp then errno is set,
which is fine in nearest rounding mode, but

  powf(0x1.7ac7cp+5, 23) is inf in upward rounding mode
  powf(-0x1.7ac7cp+5, 23) is -inf in downward rounding mode

and the previous implementation did not set errno in these cases.

The fix tries to avoid affecting the common code path or calling a
function that may introduce a stack frame, so float arithmetics is used
to check the rounding mode and the threshold is selected accordingly.

2018-12-10  Szabolcs Nagy  <szabolcs.nagy@arm.com>

	[BZ #23961]
	* math/auto-libm-test-in: Add new test case.
	* math/auto-libm-test-out-pow: Regenerated.
	* sysdeps/ieee754/flt-32/e_powf.c (__powf): Fix overflow check.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: powf-oflow.diff
Type: text/x-patch
Size: 6471 bytes
Desc: powf-oflow.diff
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20181210/15df41f2/attachment.bin>


More information about the Libc-alpha mailing list