BigRational class

Represents a rational number with arbitrary precision using BigInt for the numerator and denominator.

Constructors

BigRational(BigInt numerator, {BigInt? denominator})
Constructs a BigRational instance from the given numerator and optional denominator.
factory
BigRational.from(int numerator, {int? denominator})
Constructs a BigRational instance from the given numerator and optional denominator as integers.
factory
BigRational.parseDecimal(String decimal)
Parses a decimal string and constructs a BigRational instance from it.
factory

Properties

denominator BigInt
final
hashCode int
The hash code for this object.
no setteroverride
isDecimal bool
no setter
isNegative bool
Checks if this BigRational is negative.
no setter
isPositive bool
Checks if this BigRational is positive.
no setter
isZero bool
Checks if this BigRational is zero.
no setter
numerator BigInt
final
precision int
Gets the precision of this BigRational, which is the total number of significant digits.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scale int
Gets the scale of this BigRational, which is the number of decimal places.
no setter

Methods

abs() BigRational
ceil(dynamic toBigInt) BigRational
Rounds this BigRational towards positive infinity and returns the result as a BigRational.
compareTo(BigRational v) int
Compares this BigRational with the given BigRational and returns an integer representing the result.
encodeRational() List<int>
floor() BigRational
Returns the floor of the BigRational as a BigRational with denominator 1
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pow(int n) BigRational
Raises this BigRational to the power of n and returns the result as a BigRational.
remainder(BigRational other) BigRational
other The divisor Returns a new BigRational representing the remainder of the division.
toBigInt() BigInt
Converts the BigRational to a BigInt.
toDecimal({int? digits}) String
Converts this BigRational to its decimal representation.
toDouble() double
Converts the BigRational to a double.
toString() String
A string representation of this object.
override

Operators

operator %(BigRational other) BigRational
Computes the remainder of dividing this BigRational by the given BigRational and returns the result.
operator *(BigRational other) BigRational
Multiplies this BigRational by the given BigRational and returns the result.
operator +(BigRational other) BigRational
Adds the given BigRational to this BigRational and returns the result.
operator -(BigRational other) BigRational
Subtracts the given BigRational from this BigRational and returns the result.
operator /(BigRational other) BigRational
Divides this BigRational by the given BigRational and returns the result.
operator <(BigRational other) bool
Compares this BigRational with the given BigRational and returns true if this BigRational is less than the given BigRational.
operator <=(BigRational other) bool
Checks if this BigRational is less than or equal to the given BigRational.
operator ==(Object other) bool
The equality operator.
override
operator >(BigRational other) bool
Checks if this BigRational is greater than the given BigRational.
operator >=(BigRational other) bool
Checks if this BigRational is greater than or equal to the given BigRational.
operator unary-() BigRational
Negates this BigRational and returns the result.
operator ~() BigRational
Rounds this BigRational towards zero and returns the result as a BigRational.
operator ~/(BigRational other) BigRational
Performs integer division on this BigRational by the given BigRational and returns the result as a BigRational.

Static Properties

one BigRational
final
ten BigRational
final
zero BigRational
final

Static Methods

tryParseDecimaal(String decimal) BigRational?