nzmath.rational

Rational class

The class of rational numbers.

constructor

Rational(numerator, [denominator])

Create a rational from:

Other objects can be converted if they have toRational methods. Otherwise raise TypeError.
The default value for denominator is 1.

methods

compare(other)

decimalString(N)

Return a string of the number to N decimal places.

expand(base, limit)

r.expand(k, limit) returns the nearest rational number whose denominator is a power of k and at most limit, if k > 0. if k==0, it returns the nearest rational number whose denominator is at most limit, i.e. r.expand(0, limit) == r.trim(limit).

getRing()

Return a RationalField object.

trim(max_denominator)

Methods inherited from nzmath.ring.QuotienFieldElement:

inverse.

operators

abs, +, /, ==, float, //, >=, >, +=, //=, *=, int, **=, -=, /=, <=, <, *, !=, -

  1. , **, repr, str, __nonzero__

Last-modified: 2005-12-08 (جع) 20:45:00