Rational class

Implemented types

Constructors

Rational(BigInt numerator, [BigInt? denominator])
factory
Rational.fromInt(int numerator, [int denominator = 1])
factory
Rational.parse(String decimalValue)
factory

Properties

denominator BigInt
final
hasFinitePrecision bool
Inspect if this num has a finite precision.
no setter
hashCode int
The hash code for this object.
no setteroverride
inverse Rational
no setter
isInfinite bool
no setter
isInteger bool
no setter
isNaN bool
no setter
isNegative bool
no setter
numerator BigInt
final
precision int
The precision of this num.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scale int
The scale of this num.
no setter
signum int
The signum function value of this num.
no setter

Methods

abs() Rational
Returns the absolute value of this num.
ceil() Rational
Returns the least integer value that is no smaller than this num.
ceilToDouble() double
Returns the least integer value no smaller than this.
clamp(Rational lowerLimit, Rational upperLimit) Rational
Clamps the rational to be in the range lowerLimit-upperLimit. The comparison is done using compareTo and therefore takes -0.0 into account.
compareTo(Rational other) int
Compares this object to another object.
override
floor() Rational
Returns the greatest integer value no greater than this num.
floorToDouble() double
Returns the greatest integer value no greater than this.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pow(int exponent) Rational
Returns this to the power of exponent.
remainder(Rational other) Rational
Return the remainder from dividing this num by other.
round() Rational
Returns the integer value closest to this num.
roundToDouble() double
Returns the integer value closest to this.
toBigInt() BigInt
Truncates this num to a big integer and returns the result as an BigInt.
toDecimalString() String
toDouble() double
Return this num as a double.
toInt() int
Truncates this num to an integer and returns the result as an int.
toString() String
A string representation of this object.
override
toStringAsExponential([int? fractionDigits]) String
Converts a num to a string in decimal exponential notation with fractionDigits digits after the decimal point.
toStringAsFixed(int fractionDigits) String
Converts a num to a string representation with fractionDigits digits after the decimal point.
toStringAsPrecision(int precision) String
Converts a num to a string representation with precision significant digits.
truncate() Rational
Returns the integer value obtained by discarding any fractional digits from this num.
truncateToDouble() double
Returns the integer obtained by discarding any fractional digits from this.

Operators

operator %(Rational other) Rational
operator *(Rational other) Rational
operator +(Rational other) Rational
operator -(Rational other) Rational
operator /(Rational other) Rational
operator <(Rational other) bool
operator <=(Rational other) bool
operator ==(Object other) bool
The equality operator.
override
operator >(Rational other) bool
operator >=(Rational other) bool
operator unary-() Rational
operator ~/(Rational other) Rational
Truncating division operator.

Static Properties

one Rational
final
zero Rational
final