Home My Page Projects Code Snippets Project Openings SML/NJ Bugs
Summary Activity Tracker Lists

[#208] Real.toManExp produces incorrect results in some cases

Date:
2018-05-26 13:25
Priority:
3
State:
Open
Submitted by:
John Reppy (jhr)
Assigned to:
John Reppy (jhr)
Machine Architecture:
All
Operating System:
All
Component:
Basis Library
Resolution:
Accepted As Bug
Severity:
Major
OS Version:
SML/NJ Version:
110.82
Keywords:
Real
URL:
Transcript (of reproduction):
Standard ML of New Jersey v110.82 [built: Sat Oct 14 13:08:58 2017] - Real.toManExp(0.0); [autoloading] [library $SMLNJ-BASIS/basis.cm is stable] [library $SMLNJ-BASIS/(basis.cm):basis-common.cm is stable] [autoloading done] val it = {exp=~1022,man=0.0} : {exp:int, man:real} - Real.toManExp(1.0); val it = {exp=1,man=0.5} : {exp:int, man:real} - Real.toManExp(7.0); val it = {exp=3,man=0.875} : {exp:int, man:real} - Real.toManExp(7.9 * 2e307); val it = {exp=0,man=1.58E308} : {exp:int, man:real}
Source (for reproduction):
Real.toManExp(0.0); Real.toManExp(1.0); Real.toManExp(7.0); Real.toManExp(7.9 * 2e307);
Summary:
Real.toManExp produces incorrect results in some cases

Detailed description
This is a long standing bug (see 1228, 1319, 1362, and 1443 in the old bug list). I think that the right solution is to first add real64ToBits and bitsToRea64l primitive operations to the compiler. Then we can implement this operation (and the PackReal modules) in terms of bit manipulations.

The correct results for the above tests are:

Real.toManExp(0.0) = {exp = 0, man = 0}
Real.toManExp(1.0) = {exp = 1, man = 0.5}
Real.toManExp(7.0) = {exp = 3, man = 0.875}
Real.toManExp(7.9 * 2e307) = {exp = 1024, man = 0.878904}

so toManExp is working for 1.0 and 7.0, but not for the other two cases. There may also be a problem with subnormal arguments.

Comments:

No Comments Have Been Posted

Attached Files:

Changes

No Changes Have Been Made to This Item