num

package
v1.8.95 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2024 License: LGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidSecPwdLength      = errors.New("security password must be 6 digits")
	ErrInvalidSecPwdConsecutive = errors.New("security password must not contain three consecutive numbers")
	ErrEmptyID                  = errors.New("id is empty")
	ErrInvalidHashID            = errors.New("decoded hash id is invalid")
	ErrParseFloat               = errors.New("unable to parse string to float")
	ErrDecimalConversion        = errors.New("unable to convert string to decimal")
)

定义常见错误消息

Functions

func Calculator added in v1.8.68

func Calculator(exp string) (string, error)

Calculator 输入字符串数学表达式,将计算出结果

func CheckNumStrInRange added in v1.8.68

func CheckNumStrInRange(s string, min float64, max float64) (bool, error)

CheckNumStrInRange 检查一个字符串数字,大小是否在指定的范围内

func DecimalFormatBanker added in v1.8.68

func DecimalFormatBanker(value decimal.Decimal) string

DecimalFormatBanker 使用银行家舍入法格式化decimal类型值为两位小数

func FormatNumStrToDecimalAndShift added in v1.8.68

func FormatNumStrToDecimalAndShift(number string, decimals uint) decimal.Decimal

FormatNumStrToDecimalAndShift 输入1000,4 ,那么会输出 0.1

func GetMaxNum added in v1.8.68

func GetMaxNum(vals ...int) int

GetMaxNum 返回整数切片中的最大值

func HashIdToInt64 added in v1.8.68

func HashIdToInt64(id string, minLen uint8) (int64, error)

HashIdToInt64 将 hash ID 转换为 int64

func Int64ToHashId added in v1.8.68

func Int64ToHashId(number int64, minLen uint8) string

Int64ToHashId 将 int64 转换为 Sqids 编码的 hash ID

func MergeToDecimal added in v1.8.68

func MergeToDecimal(number *big.Int, dec int) decimal.Decimal

MergeToDecimal 如果输入的number是100000,dec是10,那么:将100000的小数点向左移动10位,得到的结果是0.00001

func StrToDecimalTruncate added in v1.8.68

func StrToDecimalTruncate(s string, precision int32) (decimal.Decimal, error)

StrToDecimalTruncate 将字符串数字变成decimal类型,保留指定小数位数,多余的全部放弃,不做四舍五入

func ValidateSecPwd

func ValidateSecPwd(secPwd string) error

ValidateSecPwd 验证交易密码

Types

This section is empty.

Jump to

Keyboard shortcuts

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