Mathematic Utilities

Mathematic Utilities #

abs #

func abs(x interface{}) interface{}
Returns the absolute value of x.
Special cases are:
    abs(±Inf) = +Inf
    abs(NaN) = NaN

Aliases #

  • absolute

Examples #

Razor:    @abs(0)
Template: {{ abs 0 }}
Result:   0
Razor:    @abs(22)
Template: {{ abs 22 }}
Result:   22
Razor:    @abs(-10)
Template: {{ abs -10 }}
Result:   10

dec #

func dec(arg1 interface{}) interface{}
Converts an hexadecimal number to decimal.

Aliases #

  • decimal

frexp #

func frexp(f interface{}) interface{}
Breaks f into a normalized fraction and an integral power of two.
Returns frac and exp satisfying f == frac × 2**exp, with the absolute
value of frac in the interval [½, 1).
Special cases are:
    frexp(±0) = ±0, 0
    frexp(±Inf) = ±Inf, 0
    frexp(NaN) = NaN, 0

gamma #

func gamma(x interface{}) interface{}
Returns the Gamma function of x.
Special cases are:
    gamma(+Inf) = +Inf
    gamma(+0) = +Inf
    gamma(-0) = -Inf
    gamma(x) = NaN for integer x < 0
    gamma(-Inf) = NaN
    gamma(NaN) = NaN

hex #

func hex(arg1 interface{}) interface{}
Formats a number as hexadecimal number.

Aliases #

  • hexa
  • hexaDecimal

hypot #

func hypot(p interface{}, q interface{}) interface{}
Returns Sqrt(p*p + q*q), taking care to avoid unnecessary overflow and
underflow.
Special cases are:
    hypot(±Inf, q) = +Inf
    hypot(p, ±Inf) = +Inf
    hypot(NaN, q) = NaN
    hypot(p, NaN) = NaN

Aliases #

  • hypotenuse

isInf #

func isInf(f interface{}, arg2 interface{}) interface{}
Reports whether f is an infinity, according to sign. If sign > 0,
isInf reports whether f is positive infinity. If sign < 0, IsInf
reports whether f is negative infinity. If sign == 0, IsInf reports
whether f is either infinity

Aliases #

  • isInfinity

isNaN #

func isNaN(f interface{}) interface{}
Reports whether f is an IEEE 754 'not-a-number' value

ldexp #

func ldexp(frac interface{}, exp interface{}) interface{}
Ldexp is the inverse of Frexp. Returns frac × 2**exp.
Special cases are:
    ldexp(±0, exp) = ±0
    ldexp(±Inf, exp) = ±Inf
    ldexp(NaN, exp) = NaN

lgamma #

func lgamma(x interface{}) interface{}
Returns the natural logarithm and sign (-1 or +1) of Gamma(x).
Special cases are:
    lgamma(+Inf) = +Inf
    lgamma(0) = +Inf
    lgamma(-integer) = +Inf
    lgamma(-Inf) = -Inf
    lgamma(NaN) = NaN

nextAfter #

func nextAfter(arg1 interface{}, arg2 interface{}) interface{}
Returns the next representable float64 value after x towards y.
Special cases are:
    Nextafter(x, x) = x
Nextafter(NaN, y) = NaN
Nextafter(x, NaN) = NaN

signBit #

func signBit(arg1 interface{}, arg2 interface{}) interface{}
Reports whether x is negative or negative zero.

sqrt #

func sqrt(x interface{}) interface{}
Returns the square root of x.
Special cases are:
    sqrt(+Inf) = +Inf
    sqrt(±0) = ±0
    sqrt(x < 0) = NaN
    sqrt(NaN) = NaN

Aliases #

  • squareRoot

to #

func to(args ...interface{}) interface{}
Builds a range of integers starting with 1 by default and including
the upper limit.

Examples #

Razor:    @to(10)
Template: {{ to 10 }}
Result:   [1,2,3,4,5,6,7,8,9,10]
Razor:    @to(10, 0)
Template: {{ to 10 0 }}
Result:   [10,9,8,7,6,5,4,3,2,1,0]
Razor:    @to(0, 10, 2)
Template: {{ to 0 10 2 }}
Result:   [0,2,4,6,8,10]

until #

func until(args ...interface{}) interface{}
Builds a range of integers starting with 0 by default and not
including the upper limit.

Examples #

Razor:    @until(10)
Template: {{ until 10 }}
Result:   [0,1,2,3,4,5,6,7,8,9]
Razor:    @until(10, 0)
Template: {{ until 10 0 }}
Result:   [10,9,8,7,6,5,4,3,2,1]
Razor:    @until(0, 10, 2)
Template: {{ until 0 10 2 }}
Result:   [0,2,4,6,8]