IEEEReal.setRoundingMode
is a no-op on Linux
#70
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
Version
v110.99.1
Operating System
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 implementrealFloor f
as#whole (Real.split f)
.Transcript
Expected Behavior
No response
Steps to Reproduce
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.
The text was updated successfully, but these errors were encountered: