NumberExtensions extension

Extension methods on num for human-readable formatting.

print(1234.toCompact());     // "1.2K"
print(1234567.toCompact());  // "1.2M"
print(3.toOrdinal());        // "3rd"
print(0.1234.toPercent());   // "12.34%"
on

Methods

toCompact({int digits = 1}) String

Available on num, provided by the NumberExtensions extension

Returns a compact, human-readable representation of this number.
toOrdinal() String

Available on num, provided by the NumberExtensions extension

Returns the ordinal representation of this integer.
toPercent({int digits = 2, bool multiply = true}) String

Available on num, provided by the NumberExtensions extension

Formats this number as a percentage string.