# Number formatter

- Page: https://koobiq.io/en/other/number-formatter/overview

Every language has its own norms for writing numbers: the decimal separator, digit grouping, the labels for thousands and millions. Formatters apply the norms of the current locale and update the output when the language changes. Use them anywhere a user reads numbers.

## Digit grouping

In large numbers, digits are grouped in threes, counting from the right. Use the `kbqNumber` pipe in text and `kbqTableNumber` in tables. The pipes differ in the threshold at which grouping starts. The numbers below follow the Russian locale; other locales use their own separator and always separate digit groups.

`kbqNumber` groups digits in numbers from 10 000 up, that is, starting from five digits: 1234, 56 789, 987 654, 1 000 000 000. In running text, a short number reads more naturally without a separator.

`kbqTableNumber` always separates digit groups: 1 234, 56 789, 987 654, 1 000 000 000. In a table, even columns make it easier to compare values by digit place from top to bottom.

## Formatting

Both pipes accept an optional `digitsInfo` string that sets the number of integer and fraction digits:

```
{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}-{useGrouping}
```

| Parameter           | Default | Description                       |
| ------------------- | ------- | --------------------------------- |
| `minIntegerDigits`  | `1`     | Minimum number of integer digits  |
| `minFractionDigits` | `0`     | Minimum number of fraction digits |
| `maxFractionDigits` | `3`     | Maximum number of fraction digits |
| `useGrouping`       | `true`  | Turns digit grouping on or off    |

For example, `'4.0-2-false'` keeps 4 integer and up to 2 fraction digits and disables grouping.

[**Example: Number-formatter** (`number-formatter-overview`)](https://koobiq.io/examples/number-formatter-overview.md)

## Abbreviated numbers

The `kbqRoundNumber` pipe displays large numbers in a short form: a thousand as `K`, a million as `M`, a billion as `B`, and so on.

[**Example: Number-formatter rounding** (`number-formatter-rounding`)](https://koobiq.io/examples/number-formatter-rounding.md)

## Choosing a locale

By default the pipes use the current application locale. Pass a locale code as the last argument to format a value in the specified locale regardless of the active one.

[**Example: Number-formatter forced locale** (`number-formatter-locale`)](https://koobiq.io/examples/number-formatter-locale.md)
