2019-10-21 04:22:28 -04:00
|
|
|
---
|
2021-08-03 05:51:36 -04:00
|
|
|
title: lang
|
|
|
|
package: lang
|
|
|
|
description: "TODO.."
|
|
|
|
date: 2021-07-28
|
2019-10-21 04:22:28 -04:00
|
|
|
categories: [functions]
|
|
|
|
keywords: [numbers]
|
|
|
|
menu:
|
|
|
|
docs:
|
|
|
|
parent: "functions"
|
|
|
|
toc: false
|
|
|
|
signature: ["lang.NumFmt PRECISION NUMBER [OPTIONS [DELIMITER]]"]
|
2021-08-03 05:51:36 -04:00
|
|
|
aliases: ['/functions/numfmt/']
|
|
|
|
type: 'template-func'
|
2019-10-21 04:22:28 -04:00
|
|
|
---
|
|
|
|
|
|
|
|
The default options value is `- . ,`. The default delimiter within the options
|
|
|
|
value is a space. If you need to use a space as one of the options, set a
|
2021-08-03 05:51:36 -04:00
|
|
|
custom delimiter.s
|
2019-10-21 04:22:28 -04:00
|
|
|
|
|
|
|
Numbers greater than or equal to 5 are rounded up. For example, if precision is set to `0`, `1.5` becomes `2`, and `1.4` becomes `1`.
|
|
|
|
|
|
|
|
```
|
|
|
|
{{ lang.NumFmt 2 12345.6789 }} → 12,345.68
|
|
|
|
{{ lang.NumFmt 2 12345.6789 "- , ." }} → 12.345,68
|
|
|
|
{{ lang.NumFmt 0 -12345.6789 "- . ," }} → -12,346
|
|
|
|
{{ lang.NumFmt 6 -12345.6789 "- ." }} → -12345.678900
|
|
|
|
{{ lang.NumFmt 6 -12345.6789 "-|.| " "|" }} → -1 2345.678900
|
|
|
|
{{ -98765.4321 | lang.NumFmt 2 }} → -98,765.43
|
|
|
|
```
|