Skip to content

autoFormatIntegerOrFloat

function autoFormatIntegerOrFloat(
number,
decimalPlaces?,
includeThousandSeparators?,
numberLocale?): string;

Defined in: packages/engine/src/utilities/Number.ts:45

Format number for display, branching on whether it’s a whole number: integers are always rendered with zero decimal places (never padded to decimalPlaces), while non-integers are rendered with up to decimalPlaces fractional digits. includeThousandSeparators controls whether groups are separated (e.g. "1,234") per numberLocale.

ParameterTypeDefault valueDescription
numbernumberundefinedThe value to format.
decimalPlacesnumber2Max fractional digits for non-integer values (default 2).
includeThousandSeparatorsbooleanfalseWhether to group digits (default false).
numberLocalestring"en-US"Intl/toLocaleString locale to format with (default “en-US”).

string