RE: Decimal type question [Prothon]

"Mark Hahn" <[email protected]> Sun, 8 Aug 2004 21:51:03 -0700
Newsgroups gmane.comp.lang.prothon.user
Message-ID <001f01c47dcc$7b0b6040$0d01a8c0@MarkVaio>
(I hope you don't mind my posting this).

Tim Peters wrote:

> Hi, Mark.  MS's Decimal type is better than nothing for 
> people who need decimal arithmetic.  It's an odd sort of 
> beast, basically a binary rational with a small number of 
> possible denominators.  The .NET docs are almost entirely 
> silent about exact semantics. leaving readers (and 
> implementers) to guess at them from staring at the handful of 
> concrete examples.
> 
> That kind of thing eventually bites, especially for numeric 
> library writers (who need to know exact intended semantics in 
> all cases).

That is dissapointing.  I was hoping it was a decent decimal type.

> In contrast, the proposed IBM standard for decimal arithmetic 
> intends to leave nothing to guesswork, and Python 2.4 has an 
> implementation:
> 
>     http://www2.hursley.ibm.com/decimal/
> 
> That's an infinitely better specification, and a better 
> arithmetic, than .NET's Decimal.  Alas, it's also a much more 
> elaborate arithmetic.
> 
> OTOH, casual users won't notice the difference, and just 
> doing away with the representation error inherent in 
> converting between decimal floats and binary floats will be a 
> huge win for them.  

Would it work well enough for my scheme to use a new Decimal type "between"
Int and Float?  What do you think of this scheme overall?  Is it an
advantage or would it be better to just stick with binary Floats except for
add-on modules?

> Some will still get burned by, e.g., that 
> 1/3*3 != 1, but many are "used to that" from hand 
> calculators.  Ironically, MS's calc.exe now uses unbounded 
> rationals under the covers, so that the next generation of 
> newbies may not be so forgiving!

I assume no one has a decimal/rational type that solves both problems at
once. :-)