Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IEEE 754] OCaml does not enable rounding direction to be specified by programs #7896

Closed
vicuna opened this issue Jan 16, 2019 · 5 comments
Closed

Comments

@vicuna
Copy link

vicuna commented Jan 16, 2019

Original bug ID: 7896
Reporter: sfuric
Status: new
Resolution: open
Priority: normal
Severity: minor
Version: 4.07.0
Category: language features
Has duplicate: #3526
Monitored by: @gasche

Bug description

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:
ocamlc -c roundingMode_stubs.c
ocamlc -c roundingMode.mli
ocamlc -c roundingMode.ml
ocamlc -custom roundingMode.cmo roundingMode_stubs.o testRounding.ml

Run:
./a.out

File attachments

@vicuna
Copy link
Author

vicuna commented Jan 16, 2019

Comment author: @nojb

I'm not an expert on IEEE754, but it sounds like a potentially useful addition. Would you like to open a PR on https://github.com/ocaml/ocaml to discuss your code?

@xavierleroy
Copy link
Contributor

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.

@Chris00
Copy link
Member

Chris00 commented Mar 16, 2019

In case this is of interest, the Interval library does this (internally).

@xavierleroy
Copy link
Contributor

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.

@github-actions
Copy link

github-actions bot commented May 6, 2020

This issue has been open one year with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. Comments that provide new information on the issue are especially welcome: is it still reproducible? did it appear in other contexts? how critical is it? etc.

@github-actions github-actions bot added the Stale label May 6, 2020
@github-actions github-actions bot closed this as completed Jun 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants