formatNumber
Formats a number with a fixed number of fraction digits using Intl.NumberFormat. Use it to keep numeric precision consistent across tables, cards, and chart labels.
Importing
ts
import { formatNumber } from '@almighty-shogun/utils'Usage
ts
import { formatNumber } from '@almighty-shogun/utils'
const amount = formatNumber(1234.567, 2, 'en');Parameters
| Name | Type | Description |
|---|---|---|
value | number | Value to format. |
decimals | number | Fraction digits. Defaults to 2. |
locale | string | Optional locale override. |
Returns
A localized number string with exactly decimals fraction digits. This is useful when table columns need visually consistent precision.
Type signature
ts
declare function formatNumber(
value: number,
decimals?: number,
locale?: string
): string;