Rational
classin packageklyn.math
public class Rational extends Object:
└ Rational
Represents a rational number with a numerator and a denominator.
Properties
Modifier and Type Member Description
public property denominator
denominator as Int:
Property for the denominator.
public property numerator
numerator as Int:
Property for the numerator.
Properties inherited from Object: type
Constructors
Modifier and Type Member Description
public Rational
Rational( num as Int = 0, den as Int = 1 ) throws ZeroDivisionError:
Constructor for Rational class.
Methods
Modifier and Type Member Description
public simplify
simplify() as Void:
Simplifies the rational number.
public override readonly toString
toString() as String:
Returns the string representation of the rational number.
Methods inherited from Object: fromJson, toDict, toJson, toString, toXml
Operators
Modifier and Type Member Description
public static operator!=(readonly notnull r1 as Rational, readonly notnull r2 as Rational) as Boolean: Value inequality between two rational numbers.
public static operator*( readonly notnull r1 as Rational, readonly notnull r2 as Rational ) as Rational: Overloaded multiplication operator for Rational numbers.
public static operator+(readonly notnull r1 as Rational, readonly notnull r2 as Rational) as Rational: Overloaded addition operator for Rational numbers.
public static operator-( readonly notnull r1 as Rational, readonly notnull r2 as Rational ) as Rational: Overloaded subtraction operator for Rational numbers.
public static operator/( readonly notnull r1 as Rational, readonly notnull r2 as Rational ) as Rational throws ZeroDivisionError: Overloaded division operator for Rational numbers.
public static operator==(readonly notnull r1 as Rational, readonly notnull r2 as Rational) as Boolean: Value equality between two rational numbers.