Arnaud Delobelle wrote:
> I'm not doing 'real world' calcultations, I'm making an app to help
> teach children maths.  I need numerical values that behave well as
> decimals. I also need them to have an arbitrary number of significant
> figures. Floats are great but they won't help me with either. Amongst
> other things, I need 3.0*0.1==0.3 to be True.

I guess that speed is not at premium in your application,
so you might try my continued fractions module,
advertised here a few weeks ago:
http://www-zo.iinf.polsl.gliwice.pl/~mciura/software/cf.py

It represents rational numbers exactly, and irrational numbers
with an arbitrary accuracy, i.e. unlike Decimal it implements
exact rather than multiple-precision arithmetic.
Once you create an expression, you can pull from it as many
decimal digits as you wish. The subexpressions dynamically
adjust their accuracy, so that you always get exact digits.

Regards,
   Marcin
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to