math

package
v0.40.1 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2018 License: Apache-2.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoArithmetic

func DoArithmetic(a, b interface{}, op rune) (interface{}, error)

DoArithmetic performs arithmetic operations (+,-,*,/) using reflection to determine the type of the two terms.

Types

type Namespace

type Namespace struct{}

Namespace provides template functions for the "math" namespace.

func New

func New() *Namespace

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

func (*Namespace) Add

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

Add adds two numbers.

func (*Namespace) Ceil added in v0.30.1

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

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

func (*Namespace) Div

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

Div divides two numbers.

func (*Namespace) Floor added in v0.30.1

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

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

func (*Namespace) Log added in v0.25.1

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

Log returns the natural logarithm of a number.

func (*Namespace) Mod

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

Mod returns a % b.

func (*Namespace) ModBool

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

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

Mul multiplies two numbers.

func (*Namespace) Round added in v0.30.1

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

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

func (*Namespace) Sub

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

Sub subtracts two numbers.

Jump to

Keyboard shortcuts

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