Python Fractions issue.

Paddy paddy3118 at
Tue Sep 23 05:44:14 CEST 2008


There seems to be a problem/difference in calculating with the new
fractions module when comparing Python 26rc2 and 30rc1

I was reading the paper "Interval Arithmetic: Python Implementation
and Applications" and thought to try the first example function
f(x,y), which needs more precision than Python floating point provides
(on my Windows PC), to calculate a sensible answer.

Ahah, I thought, lets try this with Fractions - so I first installed
Python 30rc1, typed in the Function - saw the rubbish result, then
used Fractions and got the 'right' result.
I then wondered if fractions had been back-ported to Python 2.6rc2,
found that it had, but got different results.

As you can see from the table, Python 2.6rc2 has a problem calculating
t3 = F(11,2) * y**8 + x/(2*y), where F  is Fraction.

I wonder where the problem lies?

(For the Table, please see the blog entry).

- Paddy.

More information about the Python-list mailing list