HUGO
Menu
GitHub 87548 stars Mastodon

Hugo cast.ToFloat

Hugo 將值轉換為十進制浮點數(以 10 為基數)。

Syntax

cast.ToFloat INPUT

Returns

float64

Alias

float

使用十進制(以 10 為基數)輸入:

{{ 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)

使用二進制(以 2 為基數)輸入:

{{ float 0b11 }} → 3 (float64)

使用八進制(以 8 為基數)輸入(使用任一表示法):

{{ float 011 }} → 9 (float64)
{{ float "011" }} → 11 (float64)

{{ float 0o11 }} → 9 (float64)

使用十六進制(以 16 為基數)輸入:

{{ float 0x11 }} → 17 (float64)

Last updated: January 1, 0001
Improve this page