On Jun 23, 2009, at 10:10 AM, Christian Plesner Hansen wrote:

Do you consider that naive user's calculator example to be "financial"? I do
not.

I don't know, the user doesn't say why this inaccuracy is a problem.
It sounds like he's just generally unhappy that arithmetic is
approximate.  Decimal is approximate too.

That's true at very extreme margins only! Decimal does not fail to round power-of-five products so badly, and I think you know this.

13+ years ago, I got a bug report about this calculation:

js> 79.46-39.96
39.49999999999999

This was before we founded mozilla.org, it was about Netscape 2 or 3. So the bug report prefigured bug 5856.

These dollars and cents calculations are quite common, and decimal handles them correctly with full precision and no rounding errors.


 Unless the example is set
in a context where we know we'll stay in base 10, such as financial,
decimal arithmetic will only give you less accuracy per bit.

Why are you talking about "bits" here?

Base 2 and base 5 are different, and finite precision in the latter (or base 10) can represent numbers exactly, for which no exact representation exists or can be rounded nicely using base 2 with any finite precision.


As far as I can see none of the reports collected under 5856 ask for
decimal, what they ask for is accurate arithmetic.  Decimal doesn't
provide that.  If people were asking for decimal arithmetic because
they needed it for some particular financial or scientific application
then that would be different.

See above. I think you are missing something fundamental about the problem reported at that bug. Decimal does fix it for the use-cases reported there and in dups.


Are there any other uses planned for value types than decimal?

Sure: point, rational, complex, RGBA color, quaternion, .... Some of these are esoteric, scientific programmers may care (game programmers too). Others are pretty common on the web.

/be
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to