DoubleExtensions extension

Extension methods for double values providing formatting and conversion utilities.

on

Properties

hasDecimals bool

Available on double, provided by the DoubleExtensions extension

Returns true if this double has a non-zero fractional part.
no setter

Methods

forceBetween(double from, double to) double

Available on double, provided by the DoubleExtensions extension

Clamps this value to be within the range from to to.
formatDouble(int decimalPlaces, {bool showTrailingZeros = true}) String

Available on double, provided by the DoubleExtensions extension

Returns this double formatted as a string with the specified number of decimal places.
formatPrecision({int precision = 2}) String

Available on double, provided by the DoubleExtensions extension

Returns this double formatted as a string with smart decimal handling.
toPercentage({int decimalPlaces = 0, bool doRoundDown = true}) String

Available on double, provided by the DoubleExtensions extension

Returns this double formatted as a percentage string.
toPrecision(int precision) double

Available on double, provided by the DoubleExtensions extension

Returns this double truncated to the given precision after the decimal point.