2017-08-10 11:18:22 -04:00
---
title: lang.NumFmt
2017-09-05 12:09:40 -04:00
description: "Formats a number with a given precision using the requested `negative` , `decimal` , and `grouping` options. The `options` parameter is a string consisting of `<negative> <decimal> <grouping>` ."
2017-08-10 11:18:22 -04:00
godocref: ""
workson: []
date: 2017-02-01
publishdate: 2017-02-01
2017-09-05 12:09:40 -04:00
lastmod: 2017-08-21
2017-08-10 11:18:22 -04:00
categories: [functions]
2017-09-21 13:03:00 -04:00
keywords: [numbers]
2017-08-10 11:18:22 -04:00
menu:
docs:
parent: "functions"
toc: false
2018-10-02 10:41:48 -04:00
signature: ["lang.NumFmt PRECISION NUMBER [OPTIONS [DELIMITER]]"]
2017-08-10 11:18:22 -04:00
workson: []
hugoversion:
relatedfuncs: []
deprecated: false
draft: false
aliases: []
comments:
---
2018-10-02 10:41:48 -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
custom delimiter.
2017-08-10 11:18:22 -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` .
```
2017-09-05 12:09:40 -04:00
{{ 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
2018-10-02 10:41:48 -04:00
{{ lang.NumFmt 6 -12345.6789 "-|.| " "|" }} → -1 2345.678900
2017-09-05 12:09:40 -04:00
{{ -98765.4321 | lang.NumFmt 2 }} → -98,765.43
2017-08-10 11:18:22 -04:00
```