[Cfp-interest] problem with fmaxmag code
Jim Thomas
jaswthomas at sbcglobal.net
Mon Oct 15 21:02:24 PDT 2012
The sample implementations of fmax and round have similar problems.
-Jim
On Oct 15, 2012, at 2:38 PM, Jim Thomas wrote:
> Our Part 1 draft has
>
> ------------------------------------------------
> [3] The body of the fmaxmag function might be[1]
>
>
> { return (isgreaterequal(fabs(x), fabs(y)) || isnan(y)) ? x : y; }
>
>
> [1] This implementation does not handle signaling NaNs as required of implementations that define FP_SNANS_ALWAYS_SIGNAL.
>
> ------------------------------------------------
>
> isgreaterequal might or might not raise the "invalid" floating-point exception if the implementation does not define FP_SNANS_ALWAYS_SIGNAL. Suppose it does. Suppose also that same-format conversions are copy operations. Then if x is a signaling NaN, the code would raise "invalid" but return a signaling NaN, violating F.2.1[4]. A fix would be to change the code to
>
> { return canonicalize((isgreaterequal(fabs(x), fabs(y)) || isnan(y)) ? x : y); }
>
> Then we could remove the footnote. The change would also serve to produce a canonical result.
>
> Any better ideas?
>
> -Jim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.oakapple.net/pipermail/cfp-interest/attachments/20121015/859665d5/attachment-0001.html
More information about the Cfp-interest
mailing list