DynamicInt class abstract

An efficient integer that can dynamically change its internal representation from int to BigInt.

For each operation the best representation (int or BigInt) is chosen automatically.

Implemented types
Available Extensions

Constructors

DynamicInt.fromBigInt(BigInt n)
Constructs from BigInt n.
factory
DynamicInt.fromInt(int n)
Constructs from int n.
factory
DynamicInt.fromNum(num n)
Constructs from num n.
factory
DynamicInt.parse(String s)
Parses String s to a DynamicInt integer.
factory

Properties

asDynamicIntBig DynamicInt
Returns a DynamicInt with a BigInt internal representation.
no setter
asDynamicIntNative DynamicInt
Returns a DynamicInt with a int internal representation.
no setter
bitLength int
no setter
digits int
no setter
hashCode int
The hash code for this object.
no setteroverride
isBigInt bool
Returns true if the internal representation is a BigInt.
no setteroverride
isDecimal bool
Returns true if this instance is a Decimal
no setteroverride
isDynamicInt bool
Returns true if this instance is a DynamicInt
no setteroverride
isEven bool
Returns true if and only if this integer is even.
no setteroverride
isNegative bool
Returns true if this number is negative.
no setteroverride
isOdd bool
Returns true if and only if this integer is odd.
no setteroverride
isOne bool
Returns true if this number is one.
no setteroverride
isPositive bool
Returns true if this number is positive.
no setteroverride
isSafeInteger bool
Returns true if this number is safe to be represented as int for the current Dart platform.
no setteroverride
isWholeNumber bool
Returns true if this is a whole number.
no setteroverride
isZero bool
Returns true if this number is zero.
no setteroverride
lowestSetBit int
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 setteroverride
square DynamicInt
The square of this number.
no setteroverride
squareRoot Decimal
The square root of this number.
no setterinherited

Methods

abs() DynamicInt
override
compareTo(DynamicNumber other) int
Compares this object to another object.
override
divide(num n2) DynamicNumber
override
divideAsDynamicInt(DynamicInt n2) DynamicInt
divideAsDynamicIntBig(DynamicInt other) DynamicInt
divideBigInt(BigInt n2) DynamicInt
override
divideBigIntAsDecimal(BigInt n2) Decimal
override
divideBigIntAsDouble(BigInt n2) double
inherited
divideDouble(double n2) Decimal
inherited
divideDoubleAsDecimal(double n2) Decimal
override
divideDoubleAsDouble(double n2) double
inherited
divideDynamicInt(DynamicInt other) DynamicInt
override
divideDynamicIntAsDecimal(DynamicInt other) Decimal
override
divideDynamicIntAsDouble(DynamicInt n2) double
override
divideDynamicIntAsDynamicInt(DynamicInt other) DynamicInt
inherited
divideInt(int n2) DynamicInt
override
divideIntAsDecimal(int n2) Decimal
override
divideIntAsDouble(int n2) double
inherited
divideNumAsDecimal(num n2) Decimal
override
divideNumAsDouble(num n2) double
inherited
equalsBigInt(BigInt n) bool
Returns true if n is equals to this number.
override
equalsDynamicInt(DynamicInt other) bool
Returns true if other is equals to this number.
override
equalsInt(int n) bool
Returns true if n is equals to this number.
override
format({bool thousands = true, String thousandsDelimiter = ','}) String
Formats this decimal to a String.
override
moduloBigInt(BigInt n2) DynamicInt
Euclidean modulo for BigInt n2.
override
moduloDynamicInt(DynamicInt other) DynamicInt
Euclidean modulo for DynamicInt n2.
override
moduloInt(int n2) DynamicInt
Euclidean modulo for int n2.
override
multiply(num n2) DynamicNumber
override
multiplyAsDynamicIntBig(DynamicInt other) DynamicInt
multiplyBigInt(BigInt n2) DynamicInt
override
multiplyDecimal(Decimal other) DynamicNumber
override
multiplyDouble(double n2) Decimal
override
multiplyDynamicInt(DynamicInt other) DynamicInt
override
multiplyInt(int n2) DynamicInt
override
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.
override
powerAsDecimal(DynamicNumber exponent) Decimal
This number to the power of DynamicNumber exponent as Decimal.
override
powerAsDynamicInt(DynamicNumber exponent) DynamicInt
This number to the power of DynamicNumber exponent as DynamicInt.
override
powerBigInt(BigInt exponent) DynamicNumber
This number to the power of exponent.
override
powerDouble(double exponent) DynamicNumber
This number to the power of exponent.
override
powerInt(int exponent) DynamicNumber
This number to the power of exponent.
override
powerNum(num exponent) DynamicNumber
This number to the power of exponent.
override
subtract(num n2) DynamicNumber
override
subtractAsDynamicIntBig(DynamicInt other) DynamicInt
subtractBigInt(BigInt n2) DynamicInt
override
subtractDouble(double n2) Decimal
override
subtractDynamicInt(DynamicInt other) DynamicInt
inherited
subtractInt(int n2) DynamicInt
override
sum(num n2) DynamicNumber
override
sumAsDynamicIntBig(DynamicInt other) DynamicInt
sumBigInt(BigInt n2) DynamicInt
override
sumDouble(double n2) Decimal
override
sumDynamicInt(DynamicInt other) DynamicInt
inherited
sumInt(int n2) DynamicInt
override
toBigInt() BigInt
Returns this number as BigInt.
override
toDecimal() Decimal
Returns this number as Decimal.
override
toDouble() double
Returns this number as double.
override
toDynamicInt() DynamicInt
Returns this number as DynamicInt.
override
toHex() String
This number as an integer in hexadecimal format.
inherited
toInt() int
Returns this number as int.
override
toNum() num
Returns this number as num.
inherited
toString({bool thousands = false, String thousandsDelimiter = ','}) String
A string representation of this object.
override
toStringStandard() String
Formats this number to a String in a standard format, like int or double.
inherited

Operators

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

Static Properties

maxSafeInteger int
Alias to DynamicNumber.maxSafeInteger.
final
maxSafeIntegerDigits int
Alias to DynamicNumber.maxSafeIntegerDigits.
final
minSafeInteger int
Alias to DynamicNumber.minSafeInteger.
final
minSafeIntegerDigits int
Alias to DynamicNumber.minSafeIntegerDigits.
final
negativeOne DynamicInt
final
one DynamicInt
final
safeIntegerBits int
Alias to DynamicNumber.safeIntegerBits.
final
safeIntegerShiftBits int
The safe integer bits for shift operations.
final
ten DynamicInt
final
two DynamicInt
final
zero DynamicInt
final

Static Methods

dynamicIntDigits(DynamicInt n) int
from(Object? n) DynamicInt?
Constructs from n. Accepted types: int, double, num, BigInt, String, DynamicInt.
override
intDigits(int n) int
tryParse(String s) DynamicInt?
Tries to parse String s to a DynamicInt integer.
override