hugo: Index | Files

package math

import ""

Package math provides template functions for mathmatical operations.


Package Files

init.go math.go round.go

type Namespace Uses

type Namespace struct{}

Namespace provides template functions for the "math" namespace.

func New Uses

func New() *Namespace

New returns a new instance of the math-namespaced template functions.

func (*Namespace) Add Uses

func (ns *Namespace) Add(a, b interface{}) (interface{}, error)

Add adds two numbers.

func (*Namespace) Ceil Uses

func (ns *Namespace) Ceil(x interface{}) (float64, error)

Ceil returns the least integer value greater than or equal to x.

func (*Namespace) Div Uses

func (ns *Namespace) Div(a, b interface{}) (interface{}, error)

Div divides two numbers.

func (*Namespace) Floor Uses

func (ns *Namespace) Floor(x interface{}) (float64, error)

Floor returns the greatest integer value less than or equal to x.

func (*Namespace) Log Uses

func (ns *Namespace) Log(a interface{}) (float64, error)

Log returns the natural logarithm of a number.

func (*Namespace) Mod Uses

func (ns *Namespace) Mod(a, b interface{}) (int64, error)

Mod returns a % b.

func (*Namespace) ModBool Uses

func (ns *Namespace) ModBool(a, b interface{}) (bool, error)

ModBool returns the boolean of a % b. If a % b == 0, return true.

func (*Namespace) Mul Uses

func (ns *Namespace) Mul(a, b interface{}) (interface{}, error)

Mul multiplies two numbers.

func (*Namespace) Pow Uses

func (ns *Namespace) Pow(a, b interface{}) (float64, error)

Pow returns a raised to the power of b.

func (*Namespace) Round Uses

func (ns *Namespace) Round(x interface{}) (float64, error)

Round returns the nearest integer, rounding half away from zero.

func (*Namespace) Sqrt Uses

func (ns *Namespace) Sqrt(a interface{}) (float64, error)

Sqrt returns the square root of a number. NOTE: will return for NaN for negative values of a

func (*Namespace) Sub Uses

func (ns *Namespace) Sub(a, b interface{}) (interface{}, error)

Sub subtracts two numbers.

Package math imports 6 packages (graph) and is imported by 68 packages. Updated 2020-05-14. Refresh now. Tools for package owners.