strange behaviour with simple decimals



"Stavros Macrakis" <macrakis at alum.mit.edu> writes:
...
>     It may be worth noting that both Axiom and my pocket calculator give
>     the correct answer to 3*1.4^2.
>
> To how many digits? What are the results for (3*1.4^2)-5.88 or (5/9)*9-5? or sin
> (3.1415926535897932385/4)-sqrt(1/2)?


(1) -> (3*1.4^2) - 5.88

   (1)  0.0
                                                                  Type: Float
(2) -> (5/9)*9-5

   (2)  0
                                                       Type: Fraction Integer
(3) -> sin(3.1415926535897932385/4)-sqrt(1/2)

   (3)  0.1 E -19

> I don't know how Axiom operates.  This may just be a rounding-on-display issue, or it
> may actually calculate the answer differently internally (decimal floats? rationals?)

I don't know much about the Axiom internals, either.

> Your pocket calculator may operate in decimal floating-point, in which case it will
> get exact answers for 3*1.4^2 and the like, but not for other calculations.

Interesting.  I realize that calculators typically only give
approximations, but when does it give the wrong answer when you'd
expect the right one?  (I have no doubt such cases exist; I just don't
know one offhand.)

> Do you have any suggestions on how to improve things?  

No; I'm not being very helpful.

Jay