IntX extension

Core extensions on int adding digits access and iterative range utilities.

on

Properties

digitCount → int

Available on int, provided by the IntX extension

Number of decimal digits (ignores sign). Safe against integer overflows.
no setter
digits → List<int>

Available on int, provided by the IntX extension

Individual digits, most-significant first. Optimized mathematically.
no setter
factorial → int

Available on int, provided by the IntX extension

Factorial of this value.
no setter
isNegative → bool

Available on int, provided by the IntX extension

Returns true if this value is negative.
no setter
isPositive → bool

Available on int, provided by the IntX extension

Returns true if this value is positive.
no setter
isPowerOfTwo → bool

Available on int, provided by the IntX extension

Whether this value is an exact power of two.
no setter
isPrime → bool

Available on int, provided by the IntX extension

Whether this value is a prime number.
no setter
isZero → bool

Available on int, provided by the IntX extension

Returns true if this value is zero.
no setter
nonNegative → int

Available on int, provided by the IntX extension

Returns this value clamped to zero or above.
no setter
nonPositive → int

Available on int, provided by the IntX extension

Returns this value clamped to zero or below.
no setter

Methods

clampInt(int min, int max) → int

Available on int, provided by the IntX extension

Returns this value constrained to the inclusive range [min, max].
isBetween(int min, int max) → bool

Available on int, provided by the IntX extension

Returns true if this value is between min and max inclusively.
isDivisibleBy(int divisor) → bool

Available on int, provided by the IntX extension

Returns true if this value is evenly divisible by divisor.
isMultipleOf(int factor) → bool

Available on int, provided by the IntX extension

Returns true if this value is a multiple of factor.
lcm(int other) → int

Available on int, provided by the IntX extension

Least common multiple of this value and other.
times(void action()) → void

Available on int, provided by the IntX extension

Executes action exactly this times. Equivalent to a for loop.
timesIndexed(void action(int index)) → void

Available on int, provided by the IntX extension

Executes action with the current zero-based index exactly this times.
to(int end, {int step = 1}) → Iterable<int>

Available on int, provided by the IntX extension

Inclusive range as a lazy iterable. Handles both ascending and descending ranges.