Averest


rat Type

Rational numbers rat(n,d) are constructed by two integers, the nominator n and the denominator d. We interprete numbers rat(0,d) as zero (where d!=0), and rat(n,0) as infinity.

Constructors

Constructor Description

rat(n, d)

Full Usage: rat(n, d)

Parameters:
    n : int
    d : int

Returns: rat

n : int
d : int
Returns: rat

Instance members

Instance member Description

this.d

Full Usage: this.d

Returns: int

Returns: int

this.n

Full Usage: this.n

Returns: int

Returns: int

Static members

Static member Description

r1 * r2

Full Usage: r1 * r2

Parameters:
Returns: rat

multiplication of rational numbers

r1 : rat
r2 : rat
Returns: rat

r1 + r2

Full Usage: r1 + r2

Parameters:
Returns: rat

addition of rational numbers

r1 : rat
r2 : rat
Returns: rat

r1 - r2

Full Usage: r1 - r2

Parameters:
Returns: rat

subtraction of rational numbers

r1 : rat
r2 : rat
Returns: rat

r1 / r2

Full Usage: r1 / r2

Parameters:
Returns: rat

division of rational numbers

r1 : rat
r2 : rat
Returns: rat

rat.inverse r

Full Usage: rat.inverse r

Parameters:
Returns: rat

multiplicative inverse of a rational number

r : rat
Returns: rat

rat.isNegInfinity r

Full Usage: rat.isNegInfinity r

Parameters:
Returns: bool

checking wether a number equals to zero

r : rat
Returns: bool

rat.isNegative r

Full Usage: rat.isNegative r

Parameters:
Returns: bool

checking whether a number is negative

r : rat
Returns: bool

rat.isPosInfinity r

Full Usage: rat.isPosInfinity r

Parameters:
Returns: bool

checking wether a number equals to zero

r : rat
Returns: bool

rat.isPositive r

Full Usage: rat.isPositive r

Parameters:
Returns: bool

checking whether a number is positive

r : rat
Returns: bool

rat.isZero r

Full Usage: rat.isZero r

Parameters:
Returns: bool

checking wether a number equals to zero

r : rat
Returns: bool

rat.max (r1, r2)

Full Usage: rat.max (r1, r2)

Parameters:
Returns: rat

maximum of two rational numbers

r1 : rat
r2 : rat
Returns: rat

rat.min (r1, r2)

Full Usage: rat.min (r1, r2)

Parameters:
Returns: rat

minimum of two rational numbers

r1 : rat
r2 : rat
Returns: rat

rat.negate r

Full Usage: rat.negate r

Parameters:
Returns: rat

change sign of rational numbers

r : rat
Returns: rat

rat.ofFloat x

Full Usage: rat.ofFloat x

Parameters:
    x : float

Returns: rat

conversion from a floating point number

x : float
Returns: rat

rat.parse s

Full Usage: rat.parse s

Parameters:
    s : string

Returns: rat

parsing from a string

s : string
Returns: rat

rat.toFloat r

Full Usage: rat.toFloat r

Parameters:
Returns: double

conversion to floating point numbers

r : rat
Returns: double

rat.toLatex r

Full Usage: rat.toLatex r

Parameters:
Returns: string

converting a rational number to a Latex string

r : rat
Returns: string