I have
  ScaledDecimal, based on the ANSI Smalltalk standard, but
  fixed point decimal arithmetic, because that's what the ANSI Smalltalk
  standard calls for (citing a non-existent part of the LIA standard) but
  contradicts

  FixedPoint, a version of that specifically intended for plugging into
  Squeak and/or Pharo, the snag being that I don't seem to have kept
  the change set, just the master.  I can recreate and donate the
  change set if anyone would like it.

  PackedDecimal, which just models VisualAge 31-digit packed decimal
  for interoperability, but does not do arithmetic.

On Tue, 31 Aug 2021 at 19:44, Guillermo Polito
<guillermopol...@gmail.com> wrote:
>
> Hi all,
>
> In the past months I worked a bit with it and found many problems too, like:
>  - doing scaled decimal arithmetics losing precision
>    https://github.com/pharo-project/pharo/issues/8668
>  - strange default scale values
>    https://github.com/pharo-project/pharo/issues/8669
>
> I also got hit with “downgrading" issues during my vacation coding. For 
> example, when operating a scaled decimal with a float, the result gets 
> downgraded to a float.
> See
>
>   17.777 asScaledDecimal + 0.0
>
> From all the comments I understand that the current implementation is not 
> very useful, they all lead to “do not use it, instead do XXX” where XXX is 
> either
>  - write your own
>  - load that other package
>  - use an integer to represent pennies
>
> This this means that either it can be removed, or it can benefit with a new 
> and better implementation.
> I think it would be interesting to have a better ScaledDecimal 
> implementation, that not only does precise printing but also precise 
> arithmetics.
>
> Or maybe somebody has a good implementation already available?
>
> Cheers,
> Guille
>
> > El 31 ago 2021, a las 0:58, Richard O'Keefe <rao...@gmail.com> escribió:
> >
> > Ah, you have run into the insufficiently well known
> > "ScaledDecimal looks like what you need but isn't".
> >
> > In VisualAge, you have a data type that is basically a reflection of iBM
> > mainframe "packed decimal" format, and perfectly suits the needs of
> > an SQL or COBOL interface.  It gives you round-tripping with no error.
> >
> > In my Smalltalk, ScaledDecimal is a pair (n,s) where n and s are
> > unrestricted integers, representing n * (10 raisedTo: s).  This also
> > gives you exact round-tripping and suits the needs of an SQL or COBOL
> > interface.
> >
> > However, in Squeak and Pharo, ScaledDecimal is something else
> > entirely.  Basically, a pair (q,s) where q is an Integer or Fraction,
> > and s is a scale factor used for *printing*. This doesn't just lead to
> > oddities like two unequal ScaledDecimals printing identically, it
> > leads to rounding issues. This is not a bug, it is ScaledDecimal working
> > as designed.
> >
> > Working within Squeak, the simplest approach is to represent money as
> > pence, and the next simplest is to make or find a Money class.
> >
> > On Tue, 31 Aug 2021 at 00:02, David Pennington <da...@totallyobjects.com> 
> > wrote:
> >>
> >> Hi everyone. I have a little bank analysis package for my own use but 
> >> having trouble displaying and storing amounts. I parse out a CSV file from 
> >> the bank and convert the amounts from text to ScaledDecimal. I then store 
> >> these into a STON file, which converts them back to text. I then read them 
> >> in and convert them back to ScaledDecimal again.
> >>
> >> I am not used to ~Pharo have spent 24 years using VisualAge Smalltalk so I 
> >> need a little bit of help because I am getting 1 Penny errors in the 
> >> conversions. I can cope with this but I would like to get it right.
> >>
> >> Can anyone give me a simple means of managing, say, an amount like £76.49 
> >> from the bank so that it stops coming back to me as £76.48?
> >>
> >> David
> >> Totally Objects

Reply via email to