On Fri, Feb 13, 2015 at 4:56 PM, nicolas cellier < nicolas.cellier.aka.nice@gmail.com> wrote:
...
If it's for monetary things like computing interests, then the advice is to not use Float but ScaledDecimal.
100 * (1.05s2 raisedTo: 10) roundTo: 0.01s2 -> 162.89s2
Nicolas
So, for money, I would suggest not using ScaledDecimal, but rather
FixedDecimal.
ScaledDecimal can do funny things that you would not expect in real money land:
m := 1/3 asScaledDecimal: 2. m "==> 0.33s2" m + m + m "==> 1.00s2"
You shouldn't be allowed to add 33 cents together and get a whole dollar (usd, at least)!
FixedDecimal actually rounds to the specified length (ScaledDecimal keeps the entire precision 'behind the curtains').
m := 1/3 asFixedDecimal: 2. m "==> 0.33" m + m + m "==> 0.99"
http://www.squeaksource.com/FixedDecimal.html
-cbc