[Tutor] math question
Alan Gauld
alan.gauld at blueyonder.co.uk
Fri Apr 23 18:44:15 EDT 2004
> >> should see the code and know a difference between adding
> >> .33 + .33 + .333 and 1/3 + 1/3 + 1/3
>
> > The only way the computer can do that is to parse the values,
> > apply some expert system rules:
>
> No. The above could be solved easily if Python knew how to handle
> rational numbers
OK, I admit it. Its not the only way the computer could do it.
But even here its only making the aritmetic more accurate,
Python still evaluates each term in turn, its just that it
no longer sees the 1/3 as a math operation but as a math
representation (like complex numbers).
> So if Python had rationals some problems with floats would be easier
(of
> course irrational numbers like sqrt(2) still couldn't be stored
exactly
> and for the question of the OP we needed symbolic computing).
Which was the point I was trying to make that basically Python does
arithmetic not math.
Alan G.
More information about the Tutor
mailing list