From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa2.mentor.iphmx.com (esa2.mentor.iphmx.com [68.232.141.98]) by sourceware.org (Postfix) with ESMTPS id 479F73861030 for ; Tue, 8 Sep 2020 15:06:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 479F73861030 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=joseph_myers@mentor.com IronPort-SDR: 03f9ufeOEdHUvwbeKb97A+fkrhEsS5o8P3zz5Sk51SPonmcvu1ZlJ+Wv9AD5cd+q2FLGsYG9Q/ hLJjBFAtVEf+y+sHI9TlddzV/Gi6KbiJ0ZsVLRwPC+IZ/S9oegqk4tGFKS+LsYxQIDHFIhjOj3 kQ3BjFgXFEAk2wiu5KAQm7erFnFsLteYdu0g1MW9ko53FkBssRhnqL0/NbActYza7UJPHqQskr x0WX0ucyanX/vx77NL7YthctLEYn/th8rn3TmD4UMgHqWffp1FmMzaCHrtCr2+fkzM4hwOBoC/ ZkE= X-IronPort-AV: E=Sophos;i="5.76,406,1592899200"; d="scan'208";a="52703626" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa2.mentor.iphmx.com with ESMTP; 08 Sep 2020 07:06:39 -0800 IronPort-SDR: Zb+2C3XcC16/1FWJz1Rc3Xr9pa9SM4XvP1Bsl8Qio642eL6BDVLdbqv8BBEE2wUtS61rLe+PTf FRQuW9Arb9JX0ZHpcJIeeHXvVhmKHxxaKGjSRSurD8J+M6xbztlueLuBLETgSSXaoUvqpbxJVh FR2XB40IYdsnG5LNV6fpLmUpQG8RiHEGPXhMpiSqYL5X3CKx2lRZZNA7a2widGEBtgIuO2STMt FNrnRm02n2F6P7cfNpt86PH0U3GYGrAqlgzMkcLPf0nMK7eFuFDbq00WY4I7I8qW4xVyP+Ar82 RaU= Date: Tue, 8 Sep 2020 15:06:34 +0000 From: Joseph Myers X-X-Sender: jsm28@digraph.polyomino.org.uk To: Ruinland ChuanTzu Tsai CC: Subject: Re: In libm, sin(qNaN) doesn't expect FE_INVALID ? In-Reply-To: <20200908110214.GA3365@APC301.andestech.com> Message-ID: References: <20200903123442.GA5266@APC301.andestech.com> <20200908110214.GA3365@APC301.andestech.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: SVR-IES-MBX-08.mgc.mentorg.com (139.181.222.8) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-Spam-Status: No, score=-3127.2 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8BIT X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Sep 2020 15:07:00 -0000 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