In libm, sin(qNaN) doesn't expect FE_INVALID ?
Joseph Myers
joseph@codesourcery.com
Tue Sep 8 15:06:34 GMT 2020
On Tue, 8 Sep 2020, Ruinland ChuanTzu Tsai wrote:
> If I may, I have another question upon sin,atan(±0x4p-1076), the test-
> suite expects FE_UNDERFLOW being raised.
>
> In `math/libm-test-{sin,atan}.inc` , I cannot see the corresponding
> expectation being set.
That's because tests with finite inputs and finite mathematical results
(possibly overflowing the floating-point type) generally go in
auto-libm-test-in to have the expected results generated automatically by
gen-auto-libm-tests; libm-test-*.inc are mainly for cases where the inputs
or results involve exact infinities or NaNs.
> if (k < 0x3e500000) /* if x->0 =>sin(x)=x */
> {
> math_check_force_underflow (x);
> retval = x;
> }
> ```
>
> I've read IEEE Standard Section 7.5 which regulates that if a tiny non-
> zero number is detected, an exception shall be raised. However I'm not
> so sure about the reason why the magic number is set to `0x3e500000`.
That is a check for whether the argument is small enough that the argument
itself is an accurate return value (then math_check_force_underflow does
the separate check for whether it's small enough that the underflow
exception must be raised). As sin(x) = x - x^3/6 + ..., if x^2/6 is
around 2^-54 or smaller, the error from returning x as the result is
small. That reasoning leads to the comparison of the leading bits of the
representation against 0x3e500000 (i.e. comparing |x| against 0x1p-26).
--
Joseph S. Myers
joseph@codesourcery.com
More information about the Libc-alpha
mailing list