Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
[IEEE 754] OCaml does not enable rounding direction to be specified by programs #7896
Some floating-point computations require rounding direction to be specified (typically to obtain safe bounds). However OCaml does not support directly this feature, so external functions have to be written (see attached code).
Steps to reproduce
Compile files in archive with:
FP rounding mode is another piece of global state, and I don't feel like exposing this to casual users. I'd rather leave that to a specialized, external library. Even better would be a more functional API that hides the global state. Again such an API could be developed first as an external library.
Yes, interval arithmetic is a great example of a nice, high-level, declarative API that changes rounding mode internally in the implementation.
Actually I wonder whether there are any other common use of non-default rounding modes beyond interval arithmetic.