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

IEEEReal.setRoundingMode is a no-op on Linux #70

Closed
1 of 5 tasks
JohnReppy opened this issue Jul 15, 2022 · 0 comments
Closed
1 of 5 tasks

IEEEReal.setRoundingMode is a no-op on Linux #70

JohnReppy opened this issue Jul 15, 2022 · 0 comments
Assignees
Labels
basis-lib problem with Standard ML Basis library bug Something isn't working fixed-in-110.99.3 issues that will be fixed in the 110.99.3 version floating-point problem related to floating-point operations gforge bug (or feature request) ported from smlnj-gforge repository

Comments

@JohnReppy
Copy link
Contributor

JohnReppy commented Jul 15, 2022

Version

v110.99.1

Operating System

  • All
  • Linux
  • macOS
  • Windows
  • Other Unix

OS Version

WSL

Processor

x86 (32-bit)

Component

Basis Library

Severity

Minor

Description of the problem

IEEEReal.setRoundingMode is a no-op and does not change the rounding mode.
Additional comments:
This also causes issues the functions:
Real.realTrunc, Real.realCeil, Real.realFloor, Real.realRound
since those functions are implemented in terms of IEEEReal.setRoundingMode.
Note that the default rounding mode is implementation-defined, so one and only one of these functions work properly.

Additionally, if IEEEReal.setRoundingMode is unsupported, an error should be thrown instead of silently doing nothing,
similar to other SML/NJ basis functions which are unimplemented (such as Real.fromDecimal).

Fix:
I was unable to understand how the runtime works,
but I think the C runtime may need to use the pragma
#pragma STDC FENV_ACCESS ON (http://www.cplusplus.com/reference/cfenv/FENV_ACCESS/)

One temporary fix for Real.realFloor would be to implement realFloor f as #whole (Real.split f).

Transcript

- IEEEReal.setRoundingMode IEEEReal.TO_ZERO;
val it = () : unit
- IEEEReal.getRoundingMode ();
val it = TO_NEAREST : IEEEReal.rounding_mode

Expected Behavior

No response

Steps to Reproduce

IEEEReal.setRoundingMode IEEEReal.TO_ZERO;
IEEEReal.getRoundingMode ();

Additional Information

No response

Email address

ssoss@uchicago.edu

Comments from smlnj-gforge

Original smlnj-gforge bug number 314

Submitted via web form by Skye Soss ssoss@uchicago.edu on 2022-06-02 at 19:29:00

Keywords: reals, IEEEReal

comment by @JohnReppy on 2022-06-06 14:37:00 +000 UTC

This problem appears to be specific to Linux (e.g., things work correctly on macOS). It may be because compilers are allowed to ignore the floating-point environment unless the FENV_ACCESS pragma is on.

comment by @JohnReppy on 2022-06-06 15:17:00 +000 UTC

The problem turns out to be that Linux did not support the "fenv.h" API, so it was supposed to use assembly code. Modern Linux does have that include file, so we can just use the library functions.

Fixed for 110.99.3 and 2022.1.

@JohnReppy JohnReppy added basis-lib problem with Standard ML Basis library bug Something isn't working floating-point problem related to floating-point operations gforge bug (or feature request) ported from smlnj-gforge repository labels Jul 15, 2022
@JohnReppy JohnReppy self-assigned this Jul 15, 2022
@JohnReppy JohnReppy added the fixed-in-110.99.3 issues that will be fixed in the 110.99.3 version label Jul 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
basis-lib problem with Standard ML Basis library bug Something isn't working fixed-in-110.99.3 issues that will be fixed in the 110.99.3 version floating-point problem related to floating-point operations gforge bug (or feature request) ported from smlnj-gforge repository
Projects
None yet
Development

No branches or pull requests

1 participant