This site describes solve-engine as it is on main: 2.43.0, which npm does not have yet. npm installs 2.40.0, so a page may show an answer that version does not give yet.
autoFormatIntegerOrFloat
function autoFormatIntegerOrFloat( number, decimalPlaces?, includeThousandSeparators?, numberLocale?, trimTrailingZeros?): string;Defined in: packages/engine/src/utilities/Number.ts:293
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, padded with zeros to that many unless
trimTrailingZeros is set. includeThousandSeparators controls whether
groups are separated (e.g. "1,234") per numberLocale.
Parameters
Section titled “Parameters”| Parameter | Type | Default value | Description |
|---|---|---|---|
number | number | undefined | The value to format. |
decimalPlaces | number | 2 | Max fractional digits for non-integer values (default 2). |
includeThousandSeparators | boolean | false | Whether to group digits (default false). |
numberLocale | string | "en-US" | Intl/toLocaleString locale to format with (default “en-US”). |
trimTrailingZeros | boolean | false | Whether a fraction drops the zeros that only pad it out to decimalPlaces, so 1.5 is 1.5 rather than 1.50 (default false). |
Returns
Section titled “Returns”string