NumX extension

Shared mathematical, formatting, and conversion extensions on num (covering both int and double).

on

Properties

celsiusToFahrenheit double

Available on num, provided by the NumX extension

Converts Celsius to Fahrenheit.
no setter
celsiusToKelvin double

Available on num, provided by the NumX extension

Converts Celsius to Kelvin.
no setter
fahrenheitToCelsius double

Available on num, provided by the NumX extension

Converts Fahrenheit to Celsius.
no setter
fahrenheitToKelvin double

Available on num, provided by the NumX extension

Converts Fahrenheit to Kelvin.
no setter
isWholeNumber bool

Available on num, provided by the NumX extension

Checks if the number is a whole number (has no fractional part).
no setter
kelvinToCelsius double

Available on num, provided by the NumX extension

Converts Kelvin to Celsius.
no setter
kelvinToFahrenheit double

Available on num, provided by the NumX extension

Converts Kelvin to Fahrenheit.
no setter

Methods

ceilToMultiple(num multiple) num

Available on num, provided by the NumX extension

Ceil to the nearest multiple.
floorToMultiple(num multiple) num

Available on num, provided by the NumX extension

Floor to the nearest multiple.
isBetween(num min, num max) bool

Available on num, provided by the NumX extension

Checks if the number is between min and max inclusively.
lerp(num a, num b) double

Available on num, provided by the NumX extension

Linear interpolation between a and b where this is t ∈ [0, 1].
normalized(num fromMin, num fromMax, [num toMin = 0.0, num toMax = 1.0]) double

Available on num, provided by the NumX extension

Normalizes this value from [fromMin, fromMax] into [toMin, toMax].
normalizedClamped(num fromMin, num fromMax, [num toMin = 0.0, num toMax = 1.0]) double

Available on num, provided by the NumX extension

Same as normalized but clamps the result to [toMin, toMax].
roundTo(int places) double

Available on num, provided by the NumX extension

Rounds to places decimal places.
roundToMultiple(num multiple) num

Available on num, provided by the NumX extension

Rounds to the nearest multiple.
safeNormalized(num fromMin, num fromMax, {num toMin = 0.0, num toMax = 1.0, double fallback = 0.0}) double

Available on num, provided by the NumX extension

Like normalized but returns fallback instead of throwing when source range is zero. Useful in reactive/UI code where division by zero is a transient state rather than a programmer error.