'From Squeak3.10beta of 22 July 2007 [latest update: #7137] on 3 December 2007 at 8:52:03 pm'!
"Change Set: ScaledDecimal-isLiteral-M6796-nice-Patch
Date: 3 December 2007
Author: nice
1.00s2 isLiteral used to answer false.
Note that (1 / 3.0s2) is not a well behaved literal,
because it does not re-evaluate to self...
So i propose it shall not answer true.
This patch implements this behaviour"!
!ScaledDecimal methodsFor: 'testing' stamp: 'nice 12/3/2007 20:51'!
isLiteral
"Answer if this number could be a well behaved literal.
Well, it would only if evaluating back to self.
This is not the case of all ScaledDecimals.
Some has an infinite precision and would need an infinite number of digits to print literally.
Try for example (3.00s2 reciprocal)."
^fraction denominator = 1 "first test trivial case before engaging arithmetic"
or: ["Exactly we should test:
(fraction numerator * (10 raisedTo; scale)) \\ fraction denominator = 0.
But since we can assume fraction is reduced already this will be simply:"
(10 raisedTo: scale) \\ fraction denominator = 0]
! !