On Fri, Nov 21, 2008 at 8:22 AM, Dinesh B Vadhia
<[EMAIL PROTECTED]> wrote:
> Hi Alan
>
> That's right, it is the Decimal module I'm trying to understand.  And, it is
> how to represent a decimal floating point number as a common/vulgar fraction
> eg 1.234 = 1234/1000.  How do you do this using the Decimal module?  The
> motivation is to avoid floating point calculations and use integers only
> (don't ask why!).  Cheers!

The Decimal type does not represents numbers as fractions, it
represents them as decimal floating point, i.e. a floating point
representation using base 10 instead of base 2.

A fractions module was introduced in Python 2.6 that does represent
numbers as a numerator and denominator:
http://docs.python.org/library/fractions.html

Kent
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to