NumericConditions extension
A collection of extension methods for numeric types that provide various mathematical and comparison operations.
This extension adds functionality to check numeric properties and perform mathematical calculations on numbers. It includes methods for:
- Comparison operations (greater than, less than, etc.)
- Number properties (even, odd, prime, etc.)
- Mathematical operations (square root, power)
Example usage:
void main() { int number = 7; print(number.isPositive()); // true print(number.isPrime()); // true print(number.isBetween(1, 10)); // true }
- on
Methods
-
isBetween(
num min, num max) → bool -
Available on num, provided by the NumericConditions extension
Returns whether this number falls within the rangemin
tomax
, inclusive. -
isDivisibleBy(
num divisor) → bool -
Available on num, provided by the NumericConditions extension
Returns whether this number is evenly divisible bydivisor
. -
isEven(
) → bool -
Available on num, provided by the NumericConditions extension
Returns whether this number is even. -
isGreaterOrEqual(
num value) → bool -
Available on num, provided by the NumericConditions extension
Returns whether this number is greater than or equal tovalue
. -
isGreaterThan(
num value) → bool -
Available on num, provided by the NumericConditions extension
Returns whether this number is greater thanvalue
. -
isLessOrEqual(
num value) → bool -
Available on num, provided by the NumericConditions extension
Returns whether this number is less than or equal tovalue
. -
isLessThan(
num value) → bool -
Available on num, provided by the NumericConditions extension
Returns whether this number is less thanvalue
. -
isMultipleOf(
num factor) → bool -
Available on num, provided by the NumericConditions extension
Returns whether this number is a multiple offactor
. -
isNegative(
) → bool -
Available on num, provided by the NumericConditions extension
Returns whether this number is negative (less than zero). -
isOdd(
) → bool -
Available on num, provided by the NumericConditions extension
Returns whether this number is odd. -
isPerfectSquare(
) → bool -
Available on num, provided by the NumericConditions extension
Returns whether this number is a perfect square. -
isPositive(
) → bool -
Available on num, provided by the NumericConditions extension
Returns whether this number is positive (greater than zero). -
isPrime(
) → bool -
Available on num, provided by the NumericConditions extension
Returns whether this number is prime. -
isZero(
) → bool -
Available on num, provided by the NumericConditions extension
Returns whether this number is exactly zero. -
pow(
num exponent) → num -
Available on num, provided by the NumericConditions extension
Returns this number raised to the power ofexponent
. -
sqrt(
) → double -
Available on num, provided by the NumericConditions extension
Returns the square root of this number.