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

Paul Zimmermann Paul.Zimmermann at inria.fr
Wed Feb 22 00:58:28 PST 2023


       Dear Hans,

> Could you say more about what CORE-MATH is trying to do? Or give us a
> pointer to a good paper to read?

the reference article is available at https://hal.inria.fr/hal-03721525.
The code and other references are at https://core-math.gitlabpages.inria.fr/.

> The idea is that you would have a single routine for each of these
> functions, independent of rounding mode?

yes exactly, for example we compute a double-double approximation hi + lo
of sin(x), where hi, lo are binary64 values, and obtain the correctly
rounded value by returning hi + lo, where hi + lo is rounded according
to the current rounding mode (defined using fesetround).

If the rounding mode is given explicitly to the function as in
cr_sin (x, FE_TOWARDZERO), we would need to replace hi + lo by
cr_add (hi, lo, FE_TOWARDZERO) for example.

And in all other internal operations of the cr_sin() function, what
would be the rounding mode used? Should we add an explicit rounding mode
to all operations?

> Presumably the usual implementation
> would either avoid non-motonically-increasing operations, i.e. negation,
> subtraction and division, or use them only in code that is not material to
> the accuracy of the final result?

we avoid division since it is slow, but subtraction is not an issue,
as long as we have a rigorous bound on the error

> So this code could be used to implement either C23 static rounding modes, or
> conceivably correctly rounded functions with explicit rounding mode
> parameters? It just might not be the most efficient way to do so, since you
> could call different functions for the different rounding modes instead?

adding explicit rounding mode parameters would make the code much more complex,
and would require to refactor completely the code.

Best regards,
Paul


More information about the Cfp-interest mailing list