summaryrefslogtreecommitdiffstats
path: root/docs/content/en/functions/float.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/content/en/functions/float.md')
-rw-r--r--docs/content/en/functions/float.md46
1 files changed, 33 insertions, 13 deletions
diff --git a/docs/content/en/functions/float.md b/docs/content/en/functions/float.md
index 1c589e317..e95b3ae5f 100644
--- a/docs/content/en/functions/float.md
+++ b/docs/content/en/functions/float.md
@@ -1,25 +1,45 @@
---
title: float
-linktitle: float
-description: Creates a `float` from the argument passed into the function.
-date: 2017-09-28
-publishdate: 2017-09-28
-lastmod: 2017-09-28
+description: Casts a value to a decimal (base 10) floating point value.
categories: [functions]
menu:
docs:
- parent: "functions"
-keywords: [strings,floats]
+ parent: functions
+keywords: [cast,strings,floats]
signature: ["float INPUT"]
-workson: []
-hugoversion:
relatedfuncs: []
-deprecated: false
-aliases: []
---
-Useful for turning strings into floating point numbers.
+With a decimal (base 10) input:
+```go-html-template
+{{ float 11 }} → 11 (float64)
+{{ float "11" }} → 11 (float64)
+
+{{ float 11.1 }} → 11.1 (float64)
+{{ float "11.1" }} → 11.1 (float64)
+
+{{ float 11.9 }} → 11.9 (float64)
+{{ float "11.9" }} → 11.9 (float64)
+```
+
+With a binary (base 2) input:
+
+```go-html-template
+{{ float 0b11 }} → 3 (float64)
```
-{{ float "1.23" }} → 1.23
+
+With an octal (base 8) input (use either notation):
+
+```go-html-template
+{{ float 011 }} → 9 (float64)
+{{ float "011" }} → 11 (float64)
+
+{{ float 0o11 }} → 9 (float64)
+```
+
+With a hexadecimal (base 16) input:
+
+```go-html-template
+{{ float 0x11 }} → 17 (float64)
```