[Cfp-interest 2638] Re: Floating point rounding modes

Hans Boehm boehm at acm.org
Fri Jan 27 09:07:21 PST 2023


On Fri, Jan 27, 2023 at 7:19 AM Vincent Lefevre <vincent at vinc17.net> wrote:

> On 2023-01-05 12:00:39 -0800, Hans Boehm wrote:
> > In the explicit rounding mode case, I agree the syntax is not beautiful.
> > On the other hand, for an isolated instance, in the best (AFAICT,
> > not yet implemented?) case, I think we currently have something
> > like:
> >
> > {
> >   #pragma STDC FENV_ROUND FE_TOWARDZERO;
> >   z = x + y;
> > }
> >
> > I would prefer
> >
> > z = cr_add (x, y, FE_TOWARDZERO);
> >
> > unless lots of consecutive operations use the same rounding mode, for
> which
> > I haven't seen a particularly strong use case.
>
> However, you could define an inline function cr_add_rz using the
> former syntax.
>
> Yes.
The potential advantage of the functional notation is that it's much less
intrusive on the implementation, though in C that argument may apply mostly
to the version of the proposal that does not introduce a new type. We're
potentially just adding some library code.
AFAICT, a significant problem with the current and proposed facilities is
that they are so rarely used that implementations commonly don't pay enough
attention to them. I think many implementations don't properly handle
FENV_ACCESS correctly, so I have relatively little confidence in
FENV_ROUND, especially since I think we agree it still doesn't handle
constants. I also have my doubts about FENV_ROUND in C++. I think there is
currently not even a proposal to add it there?

Hans

-- 
> Vincent Lefèvre <vincent at vinc17.net> - Web: <https://www.vinc17.net/>
> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
> _______________________________________________
> Cfp-interest mailing list
> Cfp-interest at oakapple.net
> http://mailman.oakapple.net/mailman/listinfo/cfp-interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.oakapple.net/pipermail/cfp-interest/attachments/20230127/8bc950b0/attachment.htm>


More information about the Cfp-interest mailing list