num

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs(num int) int

Abs 绝对值

func AbsFloat

func AbsFloat(num float64) float64

AbsFloat 浮点数绝对值

func Acos

func Acos(value float64) float64

Acos 反余弦

func Asin

func Asin(value float64) float64

Asin 反正弦

func Atan

func Atan(value float64) float64

Atan 反正切

func Average

func Average(nums ...int) float64

Average 平均值

func AverageFloat

func AverageFloat(nums ...float64) float64

AverageFloat 浮点数平均值

func Cbrt

func Cbrt(num float64) float64

Cbrt 立方根

func Ceil

func Ceil(num float64) int

Ceil 向上取整

func Clamp

func Clamp(num, minValue, maxValue int) int

Clamp 限制数值在指定范围内

func ClampFloat

func ClampFloat(num, minValue, maxValue float64) float64

ClampFloat 限制浮点数在指定范围内

func Cos

func Cos(angle float64) float64

Cos 余弦

func DigitCount

func DigitCount(num int) int

DigitCount 数字位数

func Factorial

func Factorial(num int) int

Factorial 阶乘

func Fibonacci

func Fibonacci(n int) int

Fibonacci 斐波那契数列

func FibonacciSequence

func FibonacciSequence(n int) []int

FibonacciSequence 生成斐波那契数列

func Floor

func Floor(num float64) int

Floor 向下取整

func FormatCurrency

func FormatCurrency(num float64, symbol string) string

FormatCurrency 格式化货币

func FormatNumber

func FormatNumber(num float64, precision int) string

FormatNumber 格式化数字

func FormatNumberWithCommas

func FormatNumberWithCommas(num float64) string

FormatNumberWithCommas 格式化数字(添加千位分隔符)

func FromBase

func FromBase(s string, base int) (int, error)

FromBase 从指定进制转换为整数

func FromBinary

func FromBinary(s string) (int, error)

FromBinary 从二进制转换为整数

func FromHex

func FromHex(s string) (int, error)

FromHex 从十六进制转换为整数

func FromOctal

func FromOctal(s string) (int, error)

FromOctal 从八进制转换为整数

func GCD

func GCD(a, b int) int

GCD 最大公约数

func IsEven

func IsEven(num int) bool

IsEven 是否为偶数

func IsInteger

func IsInteger(num float64) bool

IsInteger 是否为整数

func IsNegative

func IsNegative(num float64) bool

IsNegative 是否为负数

func IsOdd

func IsOdd(num int) bool

IsOdd 是否为奇数

func IsPerfectSquare

func IsPerfectSquare(num int) bool

IsPerfectSquare 是否为完全平方数

func IsPositive

func IsPositive(num float64) bool

IsPositive 是否为正数

func IsPrime

func IsPrime(num int) bool

IsPrime 是否为质数

func IsZero

func IsZero(num float64) bool

IsZero 是否为零

func LCM

func LCM(a, b int) int

LCM 最小公倍数

func Max

func Max(nums ...int) int

Max 求最大值

func MaxFloat

func MaxFloat(nums ...float64) float64

MaxFloat 求浮点数最大值

func Min

func Min(nums ...int) int

Min 求最小值

func MinFloat

func MinFloat(nums ...float64) float64

MinFloat 求浮点数最小值

func Mod

func Mod(a, b int) int

Mod 取模

func ModFloat

func ModFloat(a, b float64) float64

ModFloat 浮点数取模

func Pow

func Pow(base, exponent float64) float64

Pow 幂运算

func RandomFloat

func RandomFloat(minValue, maxValue float64) float64

RandomFloat 生成指定范围内的随机浮点数 [minValue, maxValue)

func RandomFloats

func RandomFloats(count int, minValue, maxValue float64) []float64

RandomFloats 生成指定数量的随机浮点数

func RandomInt

func RandomInt(minValue, maxValue int) int

RandomInt 生成指定范围内的随机整数 [minValue, maxValue]

func RandomInts

func RandomInts(count, minValue, maxValue int) []int

RandomInts 生成指定数量的随机整数

func ReverseNumber

func ReverseNumber(num int) int

ReverseNumber 反转数字

func Round

func Round(num float64) int

Round 四舍五入

func RoundTo

func RoundTo(num float64, precision int) float64

RoundTo 四舍五入到指定小数位

func Sin

func Sin(angle float64) float64

Sin 正弦

func Sqrt

func Sqrt(num float64) float64

Sqrt 平方根

func Sum

func Sum(nums ...int) int

Sum 求和

func SumFloat

func SumFloat(nums ...float64) float64

SumFloat 浮点数求和

func SumOfDigits

func SumOfDigits(num int) int

SumOfDigits 数字之和

func Tan

func Tan(angle float64) float64

Tan 正切

func ToBase

func ToBase(num, base int) string

ToBase 转换为指定进制

func ToBinary

func ToBinary(num int) string

ToBinary 转换为二进制

func ToFloat

func ToFloat(v interface{}) (float64, error)

ToFloat 转换为浮点数

func ToFloatDefault

func ToFloatDefault(v interface{}, defaultValue float64) float64

ToFloatDefault 转换为浮点数,失败返回默认值

func ToHex

func ToHex(num int) string

ToHex 转换为十六进制

func ToInt

func ToInt(v interface{}) (int, error)

ToInt 转换为整数

func ToIntDefault

func ToIntDefault(v interface{}, defaultValue int) int

ToIntDefault 转换为整数,失败返回默认值

func ToOctal

func ToOctal(num int) string

ToOctal 转换为八进制

func ToString

func ToString(v interface{}) string

ToString 转换为字符串

Types

This section is empty.

Jump to

Keyboard shortcuts

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