math

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 23, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Namespace

type Namespace struct {
	// contains filtered or unexported fields
}

Namespace defines the methods for math to be used as template functions.

func New

func New(d *deps.Deps) *Namespace

Creates a new math Namespace

func (*Namespace) Add

func (ns *Namespace) Add(i ...interface{}) int64

Add

Returns a range of numbers that have been added in `int64`

Example: {{ add 2 2 }} Returns: `4`

func (*Namespace) Ceil

func (ns *Namespace) Ceil(i interface{}) float64

Ceil

Rounds up to the nearest float value, returns `float 64`

Example: {{ ceil 9.32 }} Returns: `10`

func (*Namespace) Divide

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

Divide

Returns divided numbers in `int64`

Example: {{ divide 16 4 }} Returns: `4`

func (*Namespace) Floor

func (ns *Namespace) Floor(i interface{}) float64

Floor

Rounds down to the nearest float value , returns `float 64`

Example: {{ floor 9.62 }} Returns: `9`

func (*Namespace) Max

func (ns *Namespace) Max(a interface{}, i ...interface{}) int64

Max

Finds the largest numeric value in a slice of numbers, returns `int64`

Example: {{ max 20 1 100 }} Returns: `100`

func (*Namespace) Min

func (ns *Namespace) Min(a interface{}, i ...interface{}) int64

Min

Finds the smallest numeric value in a slice of numbers, returns `int64`

Example: {{ min 20 1 100 }} Returns: `1`

func (*Namespace) Modulus

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

Modulus

Returns remainder of two numbers in `int64`

Example: {{ mod 10 9 }} Returns: `1`

func (*Namespace) Multiply

func (ns *Namespace) Multiply(a interface{}, i ...interface{}) int64

Multiply

Returns a range of numbers that have been multiplied in `int64`

Example: {{ multiply 4 4 }} Returns: `16`

func (*Namespace) Round

func (ns *Namespace) Round(i interface{}) float64

Round

Rounds up to the nearest integer rounding halfway from zero. Returns `float 64`.

Example: {{ round 10.2 }} Returns: `10`

func (*Namespace) Subtract

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

Subtract

Returns subtracted numbers in `int64`

Example: {{ subtract 100 10 }} Returns: `90`

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL