[Cfp-interest 1953] Re: inexact exception

Jim Thomas jaswthomas at sbcglobal.net
Wed Apr 7 21:30:28 PDT 2021


Correction: The two binding tables referred to below are in F.3 #1 and F.3 #20 (in N2596).

Jim Thomas

> On Apr 7, 2021, at 9:11 PM, Jim Thomas <jaswthomas at sbcglobal.net> wrote:
> 
> Paul,
> 
> F.10 has two binding tables. The requirement for full support of the “inexact” floating-point exception is intended to apply only to the functions in the first binding table, not to the IEC 60559-recommended mathematical functions like hypot in the second table that are not required to be correctly rounded. Clarification is needed. Good catch.
> 
> Jim Thomas
> 
>> On Apr 7, 2021, at 8:12 AM, Paul Zimmermann <Paul.Zimmermann at inria.fr> wrote:
>> 
>>     Hello,
>> 
>> question: should the inexact exception be correctly raised (or not) for
>> mathematical functions?
>> 
>> In http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2596.pdf, section F.10,
>> note 10 says:
>> 
>> "Whether or when library functions not bound to operations in IEC 60559 raise the "inexact" floating-point exception is unspecified, unless stated otherwise."
>> 
>> Since hypot is described in F.10.4.4, I understand it is bound to operations
>> in IEC 60559, thus it should correctly raise inexact.
>> 
>> $ cat hypot.c
>> #include <stdio.h>
>> #include <fenv.h>
>> #include <math.h>
>> 
>> int main()
>> {
>> double x, y, z;
>> x = 1235216565974040.0;
>> y = x + 1.0;
>> printf ("x=%.6f y=%.6f\n", x, y);
>> printf ("inexact: %d\n", fetestexcept (FE_INEXACT));
>> z = hypot (x, y);
>> printf ("z=%.6f\n", z);
>> printf ("inexact: %d\n", fetestexcept (FE_INEXACT));
>> }
>> 
>> $ gcc -fno-builtin hypot.c -lm
>> $ ./a.out
>> x=1235216565974040.000000 y=1235216565974041.000000
>> inexact: 0
>> z=1746860020068409.000000
>> inexact: 32
>> 
>> x is a Pythagorean number, such that x^2+(x+1)^2 is an exact square,
>> thus we should expect that the inexact flag remains zero.
>> 
>> Is my reasoning correct?
>> 
>> Best regards,
>> Paul
>> _______________________________________________
>> Cfp-interest mailing list
>> Cfp-interest at oakapple.net
>> http://mailman.oakapple.net/mailman/listinfo/cfp-interest
> 
> 
> _______________________________________________
> Cfp-interest mailing list
> Cfp-interest at oakapple.net
> http://mailman.oakapple.net/mailman/listinfo/cfp-interest




More information about the Cfp-interest mailing list