summaryrefslogtreecommitdiffstats
path: root/docs/content/functions/NumFmt.md
blob: 6300c8e917e1be12bd9bb307a990caeda951f040 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
---
title: lang.NumFmt
description: "Formats a number with a given precision using the requested `decimal`, `grouping`, and `negative` characters."
godocref: ""
workson: []
date: 2017-02-01
publishdate: 2017-02-01
lastmod: 2017-02-01
categories: [functions]
#tags: [numbers]
menu:
  docs:
    parent: "functions"
toc: false
signature: ["lang.NumFmt <decimal> <grouping> <negative> <precision> <number>"]
workson: []
hugoversion:
relatedfuncs: []
deprecated: false
draft: false
aliases: []
comments:
---

The default options value is `- . ,`.

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 "." "" "-" 6 -12345.6789 }} → -12345.678900
{{ lang.NumFmt "." "," "-" 0 -12345.6789 }} → -12,346
{{ -98765.4321 | lang.NumFmt "." "," "-" 2 }} → -98,765.43
```