DynamicNumber<T extends DynamicNumber<T>> class abstract

A DynamicNumber is a number implementation that can guarantee precision using a dynamic internal representation for fast operations and memory optimization.

See DynamicInt and Decimal.

Implemented types
Implementers
Available Extensions

Constructors

DynamicNumber()

Properties

hashCode int
The hash code for this object.
no setteroverride
isBigInt bool
Returns true if the internal representation is a BigInt.
no setter
isDecimal bool
Returns true if this instance is a Decimal
no setter
isDynamicInt bool
Returns true if this instance is a DynamicInt
no setter
isEven bool
Returns true if and only if this number is even.
no setter
isNegative bool
Returns true if this number is negative.
no setter
isOdd bool
Returns true if and only if this number is odd.
no setter
isOne bool
Returns true if this number is one.
no setter
isPositive bool
Returns true if this number is positive.
no setter
isSafeInteger bool
Returns true if this number is safe to be represented as int for the current Dart platform.
no setter
isWholeNumber bool
Returns true if this is a whole number.
no setter
isZero bool
Returns true if this number is zero.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sign int
Returns the sign of this number. See int.sign.
no setter
square → T
The square of this number.
no setter
squareRoot Decimal
The square root of this number.
no setter

Methods

abs() → T
compareTo(DynamicNumber other) int
Compares this object to another object.
override
divide(num n2) DynamicNumber
divideBigInt(BigInt n2) → T
divideBigIntAsDecimal(BigInt n2) Decimal
divideBigIntAsDouble(BigInt n2) double
divideDouble(double n2) Decimal
divideDoubleAsDecimal(double n2) Decimal
divideDoubleAsDouble(double n2) double
divideDynamicInt(DynamicInt other) → T
divideDynamicIntAsDecimal(DynamicInt other) Decimal
divideDynamicIntAsDouble(DynamicInt n2) double
divideDynamicIntAsDynamicInt(DynamicInt other) DynamicInt
divideInt(int n2) → T
divideIntAsDecimal(int n2) Decimal
divideIntAsDouble(int n2) double
divideNumAsDecimal(num n2) Decimal
divideNumAsDouble(num n2) double
equalsBigInt(BigInt n) bool
Returns true if n is equals to this number.
equalsDynamicInt(DynamicInt other) bool
Returns true if other is equals to this number.
equalsInt(int n) bool
Returns true if n is equals to this number.
format({bool thousands = true, String thousandsDelimiter = ','}) String
Formats this number to a String.
moduloBigInt(BigInt n2) → T
Euclidean modulo for BigInt n2.
moduloDynamicInt(DynamicInt n2) → T
Euclidean modulo for DynamicInt n2.
moduloInt(int n2) → T
Euclidean modulo for int n2.
multiply(num n2) DynamicNumber
multiplyBigInt(BigInt n2) → T
multiplyDecimal(Decimal other) DynamicNumber
multiplyDouble(double n2) Decimal
multiplyDynamicInt(DynamicInt other) DynamicNumber
multiplyInt(int n2) → T
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
power(DynamicNumber exponent) DynamicNumber
This number to the power of exponent.
powerAsDecimal(DynamicNumber exponent) Decimal
This number to the power of DynamicNumber exponent as Decimal.
powerAsDynamicInt(DynamicNumber exponent) DynamicInt
This number to the power of DynamicNumber exponent as DynamicInt.
powerBigInt(BigInt exponent) DynamicNumber
This number to the power of exponent.
powerDouble(double exponent) DynamicNumber
This number to the power of exponent.
powerInt(int exponent) DynamicNumber
This number to the power of exponent.
powerNum(num exponent) DynamicNumber
This number to the power of exponent.
subtract(num n2) DynamicNumber
subtractBigInt(BigInt n2) → T
subtractDouble(double n2) Decimal
subtractDynamicInt(DynamicInt other) → T
subtractInt(int n2) → T
sum(num n2) DynamicNumber
sumBigInt(BigInt n2) → T
sumDouble(double n2) Decimal
sumDynamicInt(DynamicInt other) → T
sumInt(int n2) → T
toBigInt() BigInt
Returns this number as BigInt.
toDecimal() Decimal
Returns this number as Decimal.
toDouble() double
Returns this number as double.
toDynamicInt() DynamicInt
Returns this number as DynamicInt.
toHex() String
This number as an integer in hexadecimal format.
toInt() int
Returns this number as int.
toNum() num
Returns this number as num.
toString({bool thousands = false, String thousandsDelimiter = ','}) String
Alias to format.
override
toStringStandard() String
Formats this number to a String in a standard format, like int or double.

Operators

operator %(DynamicNumber other) DynamicNumber
Euclidean modulo operator.
operator *(DynamicNumber other) DynamicNumber
operator +(DynamicNumber other) DynamicNumber
operator -(DynamicNumber other) DynamicNumber
operator /(DynamicNumber other) Decimal
operator <(DynamicNumber other) bool
operator <<(int shiftAmount) DynamicInt
Shift the bits of this integer to the left by shiftAmount.
operator <=(DynamicNumber other) bool
operator ==(Object other) bool
The equality operator.
override
operator >(DynamicNumber other) bool
operator >=(DynamicNumber other) bool
operator >>(int shiftAmount) DynamicInt
Shift the bits of this integer to the right by shiftAmount.
operator unary-() → T
Return the negative value of this integer.
operator ~() DynamicInt
The bit-wise negate operator.
operator ~/(DynamicNumber other) DynamicInt

Static Properties

maxSafeInteger int
The maximum safe integer of the current Dart platform.
final
maxSafeIntegerAsBigInt BigInt
maxSafeInteger as BigInt.
final
maxSafeIntegerDigits int
The maximum digits of an int to be a safe integer.
final
minSafeInteger int
The minimum safe integer of the current Dart platform.
final
minSafeIntegerAsBigInt BigInt
minSafeInteger as BigInt.
final
minSafeIntegerDigits int
The minimum digits of an int to be a safe integer.
final
safeIntegerBits int
The integer bits of the current Dart platform.
final
safeIntegerShiftBits int
The safe integer bits for shift operations.
final

Static Methods

from(Object? n) DynamicNumber?
fromBigInt(BigInt n) DynamicInt
fromDouble(double n) Decimal
fromInt(int n) DynamicInt
fromNum(num n) DynamicNumber
isBigIntSafeInteger(BigInt n) bool
Returns true if BigInt n is a safe integer.
isIntSafeInteger(int n) bool
Returns true if int n is a safe integer.
parse(String s, {String decimalDelimiter = '.'}) DynamicNumber
Parses s to a DynamicInt or to a Decimal if contains . as decimal separator.
tryParse(String s, {String decimalDelimiter = '.'}) DynamicNumber?
Tries to parse s.