math
math.Add
Add adds two numbers.
Aliases: add
Examples
{{add 1 2}}
3
math.Ceil
Ceil returns the least integer value greater than or equal to x
.
Examples
{{math.Ceil 2.1}}
3
math.Counter
() → uint64
Counter increments and returns a global counter. This was originally added to be used in tests where now.UnixNano did not have the needed precision (especially on Windows). Note that given the parallel nature of Hugo, you cannot use this to get sequences of numbers, and the counter will reset on new builds.
math.Div
Div divides two numbers.
Aliases: div
Examples
{{div 6 3}}
2
math.Floor
Floor returns the greatest integer value less than or equal to x
.
Examples
{{math.Floor 1.9}}
1
math.Log
Log returns the natural logarithm of a
number.
Examples
{{math.Log 1}}
0
math.Max
Max returns the greater of two numbers.
Examples
{{math.Max 1 2 }}
2
math.Min
Min returns the smaller of two numbers.
Examples
{{math.Min 1 2 }}
1
math.Mod
Mod returns a
% b.
Aliases: mod
Examples
{{mod 15 3}}
0
math.ModBool
ModBool returns the boolean of a
% b. If a
% b == 0, return true.
Aliases: modBool
Examples
{{modBool 15 3}}
true
math.Mul
Mul multiplies two numbers.
Aliases: mul
Examples
{{mul 2 3}}
6
math.Pow
Pow returns a
raised to the power of b.
Aliases: pow
Examples
{{math.Pow 2 3}}
8
math.Round
Round returns the nearest integer, rounding half away from zero.
Examples
{{math.Round 1.5}}
2
math.Sqrt
Sqrt returns the square root of a
number.
Examples
{{math.Sqrt 81}}
9
math.Sub
Sub subtracts two numbers.
Aliases: sub
Examples
{{sub 3 2}}
1