numberutil

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(a, b float64) float64

Add 进行加法运算

func BinaryToInt

func BinaryToInt(s string) (int, error)

BinaryToInt 二进制转 int

func Compare

func Compare(a, b float64) int

Compare 比较两个值的大小

func DecimalFormat

func DecimalFormat(format string, value int64) string

DecimalFormat 格式化数字

func Div

func Div(a, b float64, precision int, roundMode string) float64

Div 进行除法运算,支持指定小数位数和舍入方式

func Divisor

func Divisor(a, b int) int

Divisor 计算最大公约数

func Factorial

func Factorial(n int) int

Factorial 计算阶乘

func Fibonacci

func Fibonacci(n int) int

Fibonacci 计算斐波那契数列的第n个数

func GenerateRandomNumber

func GenerateRandomNumber(min, max, count int) []int

GenerateRandomNumber 生成不重复随机数

func GetBinaryStr

func GetBinaryStr(n int) string

GetBinaryStr 获取数字对应的二进制字符串

func IsDouble

func IsDouble(value string) bool

IsDouble 检查是否为浮点数

func IsEven

func IsEven(n int) bool

IsEven 检查是否为偶数

func IsInteger

func IsInteger(value string) bool

IsInteger 检查是否为整数

func IsNumber

func IsNumber(value string) bool

IsNumber 检查是否为数字

func IsOdd

func IsOdd(n int) bool

IsOdd 检查是否为奇数

func IsPrime

func IsPrime(num int) bool

IsPrime 检查是否为质数

func Mul

func Mul(a, b float64) float64

Mul 进行乘法运算

func Multiple

func Multiple(a, b int) int

Multiple 计算最小公倍数

func Round

func Round(value float64, precision int) float64

Round 四舍五入

func RoundStr

func RoundStr(value float64, precision int) string

RoundStr 四舍五入并返回字符串

func Sqrt

func Sqrt(x float64) float64

Sqrt 计算平方根

func Sub

func Sub(a, b float64) float64

Sub 进行减法运算

func ToStr

func ToStr(value float64) string

ToStr 数字转字符串,并自动去除尾部多余的 0

Types

This section is empty.

Jump to

Keyboard shortcuts

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