math

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2022 License: BSD-2-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbsFloat

func AbsFloat(num float64) float64

AbsFloat returns the absolute float64 value of float64 num.

func AbsFloat64

func AbsFloat64(num float64) float64

AbsFloat64 returns the absolute float64 value of float64 num.

func AbsInt

func AbsInt(num int) int

AbsInt returns the absolute int value of int num.

func AbsInt64

func AbsInt64(num int64) int64

AbsInt64 returns the absolute int64 value of int64 num.

func Average

func Average(nums ...interface{}) float64

Average returns the float64 average of nums.

func AverageFloat

func AverageFloat(nums ...float64) float64

AverageFloat returns the float64 average of float64 nums.

func AverageFloat64

func AverageFloat64(nums ...float64) float64

AverageFloat64 returns the float64 average of float64 nums.

func AverageInt

func AverageInt(nums ...int) float64

AverageInt returns the float64 average of int nums.

func AverageInt64

func AverageInt64(nums ...int64) float64

AverageInt64 returns the float64 average of int64 nums.

func Compare

func Compare(f1, f2 float64, places ...int) int

Compare compares f1 and f2 and returns:

-1 if   f1 < f2
 0 if | f1 - f2 | <= 10 ^ -places, default places is 9
+1 if   f1 > f2

func Equal

func Equal(f1, f2 float64, places ...int) bool

Equal reports whether f1 and f2 are equal.

func GreaterThan

func GreaterThan(f1, f2 float64, places ...int) bool

GreaterThan (GT) returns true when f1 is greater than f2.

func GreaterThanOrEqual

func GreaterThanOrEqual(f1, f2 float64, places ...int) bool

GreaterThanOrEqual (GTE) returns true when f1 is greater than or equal to f2.

func IsEven

func IsEven(num int64) bool

IsEven reports whether num is even number.

func IsNegative

func IsNegative(f float64) bool

IsNegative returns:

 true if d <  0
false if d == 0
false if d >  0

func IsNonNegative

func IsNonNegative(f float64) bool

IsNonNegative returns:

 true if d >  0
 true if d == 0
false if d <  0

func IsNonPositive

func IsNonPositive(f float64) bool

IsNonPositive returns:

 true if d <  0
 true if d == 0
false if d >  0

func IsOdd

func IsOdd(num int64) bool

IsOdd reports whether num is odd number.

func IsPositive

func IsPositive(f float64) bool

IsPositive returns:

 true if d >  0
false if d == 0
false if d <  0

func IsZero

func IsZero(f float64) bool

IsZero returns:

 true if d == 0
false if d >  0
false if d <  0

func LessThan

func LessThan(f1, f2 float64, places ...int) bool

LessThan (LT) returns true when f1 is less than f2.

func LessThanOrEqual

func LessThanOrEqual(f1, f2 float64, places ...int) bool

LessThanOrEqual (LTE) returns true when f1 is less than or equal to f2.

func Max

func Max(nums ...interface{}) float64

Max returns the largest float64 number in nums.

func MaxFloat

func MaxFloat(nums ...float64) float64

MaxFloat returns the largest float64 number in float64 nums.

func MaxFloat64

func MaxFloat64(nums ...float64) float64

MaxFloat64 returns the largest float64 number in float64 nums.

func MaxInt

func MaxInt(nums ...int) int

MaxInt returns the largest int number in int nums.

func MaxInt64

func MaxInt64(nums ...int64) int64

MaxInt64 returns the largest int64 number in int64 nums.

func Min

func Min(nums ...interface{}) float64

Min returns the smallest float64 number in nums.

func MinFloat

func MinFloat(nums ...float64) float64

MinFloat returns the smallest float64 number in float64 nums.

func MinFloat64

func MinFloat64(nums ...float64) float64

MinFloat64 returns the smallest float64 number in float64 nums.

func MinInt

func MinInt(nums ...int) int

MinInt returns the smallest int number in int nums.

func MinInt64

func MinInt64(nums ...int64) int64

MinInt64 returns the smallest int64 number in int64 nums.

func NumberFormat

func NumberFormat(num float64, places int, separator ...string) string

NumberFormat returns the formatted num with grouped thousands.

func Percent

func Percent(num, total interface{}) float64

Percent returns the float64 percentage of num in total.

func RandFloat

func RandFloat(min, max float64) float64

RandFloat returns float64 pseudo-random number in [min, max).

func RandFloat64

func RandFloat64(min, max float64) float64

RandFloat64 returns float64 pseudo-random number in [min, max).

func RandInt

func RandInt(min, max int) int

RandInt returns int pseudo-random number in [min, max).

func RandInt64

func RandInt64(min, max int64) int64

RandInt64 returns int64 pseudo-random number in [min, max).

func RangeFloat

func RangeFloat(start, stop float64, step ...float64) []float64

RangeFloat returns a float64 slice, starting from float64 start, and increments by float64 step, and stops before float64 stop. If start < stop, default step is 1, else default step is -1.

func RangeFloat64

func RangeFloat64(start, stop float64, step ...float64) []float64

RangeFloat64 returns a float64 slice, starting from float64 start, and increments by float64 step, and stops before float64 stop. If start < stop, default step is 1, else default step is -1.

func RangeInt

func RangeInt(start, stop int, step ...int) []int

RangeInt returns a int slice, starting from int start, and increments by int step, and stops before int stop. If start < stop, default step is 1, else default step is -1.

func RangeInt64

func RangeInt64(start, stop int64, step ...int64) []int64

RangeInt64 returns a int64 slice, starting from int64 start, and increments by int64 step, and stops before int64 stop. If start < stop, default step is 1, else default step is -1.

func Round

func Round(f float64, places int) float64

Round rounds the f to places.

func RoundBank

func RoundBank(f float64, places int) float64

RoundBank banker rounds the f to places.

func RoundBankToString

func RoundBankToString(f float64, places int) string

RoundBankToString returns a banker rounded fixed-point string with places digits after the f point.

func RoundToString

func RoundToString(f float64, places int) string

RoundToString returns a rounded fixed-point string with places digits after the f point.

func Sign

func Sign(f float64) int

Sign returns:

-1 if f <  0
 0 if f == 0
+1 if f >  0

func SizeFormat

func SizeFormat(size float64, places int, separator ...string) string

SizeFormat returns the formatted size with storage unit.

func Sum

func Sum(nums ...interface{}) float64

Sum returns the float64 sum of nums.

func SumFloat

func SumFloat(nums ...float64) float64

SumFloat returns the float64 sum of float64 nums.

func SumFloat64

func SumFloat64(nums ...float64) float64

SumFloat64 returns the float64 sum of float64 nums.

func SumInt

func SumInt(nums ...int) int

SumInt returns the int sum of int nums.

func SumInt64

func SumInt64(nums ...int64) int64

SumInt64 returns the int64 sum of int64 nums.

Types

This section is empty.

Jump to

Keyboard shortcuts

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