# HG changeset patch # User Claus Gittinger # Date 1559758128 -7200 # Node ID 3d3652e1f81ce73484914d9d926b19b204606360 # Parent 6dfccbe099d39d40dd4f2deb52dc485a3cac271a #BUGFIX by cg class: LargeFloat NaN and Inf fixes comment/format in: #negative changed: #asFloat #asTrueFraction #positive diff -r 6dfccbe099d3 -r 3d3652e1f81c LargeFloat.st --- a/LargeFloat.st Wed Jun 05 18:35:08 2019 +0200 +++ b/LargeFloat.st Wed Jun 05 20:08:48 2019 +0200 @@ -711,7 +711,7 @@ mantissa == 0 ifTrue:[ "/ INF or NAN ^ self class - raise:#conversionErrorSignal + raise:#domainErrorSignal receiver:self selector:#asTrueFraction arguments:#() @@ -748,6 +748,8 @@ LargeFloat infinity asTrueFraction -> error LargeFloat negativeInfinity asTrueFraction -> error " + + "Modified: / 05-06-2019 / 20:06:20 / Claus Gittinger" ! coerce:aNumber @@ -812,10 +814,13 @@ !LargeFloat methodsFor:'converting'! asFloat - "Convert to a IEEE 754 double precision floating point." - - precision > Float precision ifTrue: [^(self copy setPrecisionTo: Float precision) asFloat]. - ^mantissa asFloat timesTwoPower: biasedExponent + "Convert to a IEEE 754 double precision floating point." + + mantissa == 0 ifTrue:[^ Float NaN]. + precision > Float precision ifTrue: [^(self copy setPrecisionTo: Float precision) asFloat]. + ^mantissa asFloat timesTwoPower: biasedExponent + + "Modified: / 05-06-2019 / 20:06:36 / Claus Gittinger" ! asFraction @@ -2653,12 +2658,17 @@ negative "return true if the receiver is negative" - mantissa == 0 ifTrue:[ ^ biasedExponent negative]. + mantissa == 0 ifTrue:[ ^ biasedExponent negative]. "/ +/-INF ^ mantissa negative + + "Modified (comment): / 05-06-2019 / 20:08:19 / Claus Gittinger" ! positive - ^mantissa positive + mantissa == 0 ifTrue:[^ biasedExponent positive]. "/ +/-INF + ^ mantissa positive + + "Modified (comment): / 05-06-2019 / 20:08:07 / Claus Gittinger" ! sign