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

Formats this double to a string with a specified number of decimal places.
formatPrecision({int precision = 2}) String

Available on double, provided by the DoubleExtensions extension

Formats this double with smart decimal handling.
toPercentage({int decimalPlaces = 0, bool roundDown = true}) String

Available on double, provided by the DoubleExtensions extension

Formats this double value as a percentage string.
toPrecision(int precision) double

Available on double, provided by the DoubleExtensions extension

Truncates this double to a given precision after the decimal point.