Rational class final
A rational representation with numerator and denominator.
- Implemented types
- Available extensions
- Annotations
-
- @immutable
Constructors
- Rational(int _numerator, [int _denominator = 1])
-
Creates a new Rational from
_numerator
and_denominator
.const - Rational.fromDouble(double number, {int tolerance = 100})
-
Creates a new Rational from
number
andtolerance
.factory - Rational.fromMixed(int wholePart, [int numerator = 0, int _denominator = 1])
-
Creates a new Rational from
wholePart
,numerator
, and_denominator
.const - Rational.parse(String source)
-
Parses source as a Rational.
factory
Properties
Methods
-
compareTo(
Rational other) → int -
Compares this object to another object.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDouble(
) → double - This Rational as a double.
-
toInt(
) → int - Truncates this Rational to an integer and returns the result as an int.
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator *(
Rational other) → Rational -
Multiplies this Rational with
other
. -
operator +(
Rational other) → Rational -
Adds this Rational to
other
. -
operator -(
Rational other) → Rational -
Subtracts
other
from this Rational. -
operator /(
Rational other) → Rational -
Divides this Rational with
other
. -
operator ==(
Object other) → bool -
The equality operator.
override
-
operator unary-(
) → Rational - Negates this Rational.