[Cfp-interest 1957] Re: inexact exception

Jim Thomas jaswthomas at sbcglobal.net
Thu Apr 8 16:55:40 PDT 2021


Note that the first table (F.3 #1) is labeled “Operation binding” and the second table (F.3 #20) is unlabeled. The C functions in the second table correspond to the recommended mathematical operations in IEC 60559 but aren’t strictly bound to them because the C functions are not required to correctly round or to honor rounding direction modes. 

The simple clarification might be to change the two instances in F.10 of "functions not bound to operations in IEC 60559” to "functions not listed in the Operation binding table in F.3”.

Jim Thomas

> On Apr 7, 2021, at 9:30 PM, Jim Thomas <jaswthomas at sbcglobal.net> wrote:
> 
> 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
> 
> 
> _______________________________________________
> 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