Hi,
The type of Real.fromDecimal
Poly/ML 5.1 Testing
Real.fromDecimal ;
val it = fn : IEEEReal.decimal_approx -> Real.real
SML# 0.30 (2007-07-03 16:16:12 JST) # Real.fromDecimal ; val it = fn : IEEEReal.decimal_approx -> Real.Math.real
Standard ML of New Jersey v110.66 [built: Thu Oct 25 11:43:30 2007] - Real.fromDecimal ; [autoloading] [library $SMLNJ-BASIS/basis.cm is stable] [autoloading done] val it = fn : IEEEReal.decimal_approx -> real
disagrees with the Basis Library specification (http://www.standardml.org/Basis/real.html#SIG:REAL.toDecimal:VAL)
val fromDecimal : IEEEReal.decimal_approx -> real option
in all of the three compiler's implementation of the Basis Library. Also note that the description in the Basis Library spec includes the equation
fromDecimal (toDecimal r) = r
which is incorrect, of course.
-Vesa Karvonen
Vesa Karvonen wrote:
The type of Real.fromDecimal
Poly/ML 5.1 Testing
Real.fromDecimal ;
val it = fn : IEEEReal.decimal_approx -> Real.real
disagrees with the Basis Library specification (http://www.standardml.org/Basis/real.html#SIG:REAL.toDecimal:VAL)
I've fixed this (in CVS) to return the option type rather than raise an exception. I've also taken a closer look at the string to real conversion functions and made a few changes to bring it in line with the current version of the basis library. In particular they no longer raise exceptions if they overflow or underflow but instead generate signed infinities or zeros. This has the consequence that real constants in ML code are also silently converted to zeros or infinities if they underflow or overflow. It might be better to have a warning message in that case but given the way the conversion process is handled that's difficult to achieve. To be honest the real number handling in Poly/ML would benefit from being looked at by someone who fully understands IEEE arithmetic.
David.