NumberFormatter
Number formatting for display, and its locale-independent counterpart.
format follows the OS locale, because a number shown to a user should read the way that user writes numbers. formatInvariant keeps a fixed dot separator and no grouping, for the few strings that are not prose: interop payloads another system parses, and values that get re-parsed rather than read.
Functions
Formats with a fixed dot separator and no grouping, whatever the locale.
Float overload of formatInvariant.
True when char is a decimal mark reachable from a Decimal/DecimalSigned keyboard.
True when text could still become a number as the user types — an empty field, a lone sign, or a trailing separator. A controlled field consults this after parseDecimalOrNull returns null, so transient input like - or -. survives on the way to -1.5 instead of snapping back to the last committed value.
Parses a user-entered decimal whose separator follows the keyboard locale — 48,21 on a comma locale, which String.toDoubleOrNull rejects. A lone separator is always the decimal mark; grouping is only recognised when more than one appears, in which case the last one is the decimal mark. Returns null for anything unparseable.