mirror of
https://github.com/gohugoio/hugo.git
synced 2026-09-03 20:22:38 +00:00
abe797c958
Also create the first draft of NumFmt function.
42 lines
976 B
Markdown
42 lines
976 B
Markdown
---
|
|
title: numfmt
|
|
linktitle: 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: []
|
|
toc: false
|
|
ns: "lang"
|
|
signature: ["NumFmt <decimal> <grouping> <negative> <precision> <number>"]
|
|
workson: []
|
|
hugoversion:
|
|
relatedfuncs: []
|
|
deprecated: false
|
|
draft: true
|
|
aliases: []
|
|
comments:
|
|
---
|
|
|
|
`NumFmt` formats a number with a given precision using the requested `decimal`,
|
|
`grouping`, and `negative` characters.
|
|
|
|
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
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|