Rational class

Rational number represented as a fraction of two BigInts

Inheritance

Constructors

Rational.fraction(BigInt numerator, BigInt denominator, {bool reduce = true})
factory
Rational.intFraction(int numerator, int denominator)
factory
Rational.parse(String value)
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scale int
no setterinherited

Methods

abs() Decimal
Absolute value
inherited
compareTo(Decimal other) int
Compare two Decimals
NOTES:
override
divide(Decimal other, {int? scale, RoundingMode? mode}) Decimal
inherited
halfUp(int scale) Decimal
Rounds to specified scale using half-up rounding mode
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
strictEquals(Decimal other) bool
Strict equality check (including scale)
override
toBigInt() BigInt
Convert to BigInt (truncating decimal part)
inherited
toDouble() double
Convert to double (may lose precision)
override
toInt() int
Convert to int (truncating decimal part)
inherited
toRational() Rational
override
toString() String
Convert to plain string representation.
Examples:
override
withScale(int scale, RoundingMode mode) Decimal
Convert to Decimal with specified scale and rounding mode
override

Operators

operator *(Decimal other) Decimal
Multiplication
override
operator +(Decimal other) Decimal
Addition
override
operator -(Decimal other) Decimal
Subtraction
override
operator /(Decimal other) Decimal
Division, may return Rational if not exact decimal
Examples:
override
operator <(Decimal other) bool
Less than
inherited
operator <=(Decimal other) bool
Less than or equal to
inherited
operator ==(Object other) bool
Equal to
override
operator >(Decimal other) bool
Greater than
inherited
operator >=(Decimal other) bool
Greater than or equal to
inherited
operator unary-() Decimal
Subtraction
override