smlnj / legacy

This project is the old version of Standard ML of New Jersey that continues to support older systems (e.g., 32-bit machines).
BSD 3-Clause "New" or "Revised" License
29 stars 9 forks source link

`Real.realMod` and `Real.split` produce incorrect result for values close to zero #269

Closed pclayton closed 6 months ago

pclayton commented 1 year ago

Version

110.99.3 (Latest)

Operating System

OS Version

No response

Processor

System Component

Basis Library

Severity

Minor

Description

For x : real where 0.0 < Real.abs x and Real.abs x <= 1E~16, both Real.realMod x #frac (Real.split x) return 0.0 but should instead return x.

Transcript

- Standard ML of New Jersey (64-bit) v110.99.3 [built: Thu Sep 22 14:05:58 2022]
- val x = 1E~16;
val x = 1E~16 : real
- Real.realMod x;
[autoloading]
[library $SMLNJ-BASIS/basis.cm is stable]
[library $SMLNJ-BASIS/(basis.cm):basis-common.cm is stable]
[autoloading done]
val it = 0.0 : real
- Real.class it;
val it = ZERO : IEEEReal.float_class
- #frac (Real.split x);
val it = 0.0 : real
- Real.class it;
val it = ZERO : IEEEReal.float_class
- val x = ~1E~16;
val x = ~1E~16 : real
- Real.realMod x;
val it = 0.0 : real
- Real.class it;
val it = ZERO : IEEEReal.float_class
- #frac (Real.split x);
val it = 0.0 : real
- Real.class it;
val it = ZERO : IEEEReal.float_class

Expected Behavior

See description.

Steps to Reproduce

val x = 1E~16;
Real.realMod x;        (* should not be 0.0 *)
Real.class it;         (* should not be ZERO *)
#frac (Real.split x);  (* should not be 0.0 *)
Real.class it;         (* should not be ZERO *)

Additional Information

No response

Email address

phil.clayton@veonix.com

JohnReppy commented 6 months ago

This was fixed on February 29. The fix will be included in 110.99.5.