<div dir="ltr">[I'm not sure whether this will reach cfp-interest; feel free to forward if not. ]<div><br></div><div>Disclaimer: I have no confidence in my ability to design an API here that would actually make it through the various C++ subcommittees. Hence the vague nature of the initial proposal. My plan is to have the next revision contain a more specific syntax proposal. But:<div><br></div><div>The simplest acceptable (to me) proposal would be to change the above to:</div><div><br></div><div>   double x, y;<br>   y = cr_sin_explicit(x, FE_TOWARDZERO);<br></div><div><br></div><div>(This uses the atomics-inspired _explicit syntax to get around the absence of overloading. That's not great, but there is a precedent.)</div><div><br></div><div>At least in C++, I think there are reasons to do something a bit more elaborate. There may also be reasons not to, especially based on C compatibility.</div><div><br></div><div>Does C23 have a way to specify rounding of decimal constants to binary floating point? My impression was no. I think that's another usability obstacle that should be addressed if we really want to make directed rounding usable to get a bound on the true result.</div><div><br></div><div>My concern with this kind of syntax in a C++ context is that it's rather easy to accidentally mix in an operation or conversion that does not obey the intended rounding rules. That's why the current strawman C++ proposal instead introduces a new type. With that approach. the C syntax might look more like</div><div><br></div><div>   cr_double x, y;<br>   y = sin_explicit(x, FE_TOWARDZERO);<br></div><div><br></div><div>or perhaps just</div><div><br></div><div>   cr_double x, y;<br>   y = sin(x, FE_TOWARDZERO);<br></div><div><br></div><div>A major goal here is really to make the value of floating point expressions independent of the context in which they appear. That problem showed up in the constexpr discussions this morning.</div></div><div><br></div><div>Hans</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jan 3, 2023 at 11:45 PM Paul Zimmermann <<a href="mailto:Paul.Zimmermann@inria.fr">Paul.Zimmermann@inria.fr</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">       Hi Hans,<br>
<br>
I have read your proposal. Currently in C if we want correct rounding of the<br>
sine function towards zero we write (assuming the math library supports<br>
correct rounding, or using the new C23 cr_sin function):<br>
<br>
   double x, y;<br>
   fesetround (FE_TOWARDZERO);<br>
   y = sin (x); /* or y = cr_sin(x) */<br>
<br>
What would be the corresponding lines in your proposal in the *C* language?<br>
(As far as I know, this mailing list only covers C, not C++.)<br>
<br>
Best regards,<br>
Paul <br>
</blockquote></div>