math

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2026 License: MIT, Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidBase32 = errors.New("invalid base32")

ErrInvalidBase32 is returned by ParseBase32 when given an invalid []byte

View Source
var ErrInvalidBase58 = errors.New("invalid base58")

ErrInvalidBase58 is returned by ParseBase58 when given an invalid []byte

Functions

func DecimalPlaces

func DecimalPlaces(value float64, prec int) float64

func DecimalPlacesRound

func DecimalPlacesRound(value float64, rank int) float64

四舍五入

func FormatFloat

func FormatFloat(num float64) string

func FormatInt

func FormatInt(i int64, base int) string

FormatInt returns the string representation of i in the given base, for 2 <= base <= 36. The result uses the lower-case letters 'a' to 'z' for digit values >= 10.

func FormatUint

func FormatUint(i uint64, base int) string

FormatUint returns the string representation of i in the given base, for 2 <= base <= 36. The result uses the lower-case letters 'a' to 'z' for digit values >= 10.

func FormatUintBase32 added in v1.7.17

func FormatUintBase32(f uint64) string

FormatUintBase32 uses the z-base-32 character set but encodes and decodes similar to base58, allowing it to create an even smaller result string. NOTE: There are many different base32 implementations so becareful when doing any interoperation.

func FormatUintBase58 added in v1.7.17

func FormatUintBase58(f uint64) string

FormatUintBase58 returns a base58 string of the uint64

func GenKey

func GenKey(key int64) int64

func Max

func Max[T constraintsi.Ordered](data ...T) T

func Min

func Min[T constraintsi.Ordered](data ...T) T

func MinAndMax

func MinAndMax[T constraintsi.Ordered](data ...T) (T, T)

func ParseBase32Uint added in v1.7.17

func ParseBase32Uint(b []byte) (uint64, error)

ParseBase32Uint parses a base32 []byte into a uint64 NOTE: There are many different base32 implementations so becareful when doing any interoperation.

func ParseBase58Uint added in v1.7.17

func ParseBase58Uint(b []byte) (uint64, error)

ParseBase58Uint parses a base58 []byte into a uint64

func ParseInt

func ParseInt(s string, base int, bitSize int) (i int64, err error)

ParseInt interprets a string s in the given base (0, 2 to 36) and bit size (0 to 64) and returns the corresponding value i.

The string may begin with a leading sign: "+" or "-".

If the base argument is 0, the true base is implied by the string's prefix following the sign (if present): 2 for "0b", 8 for "0" or "0o", 16 for "0x", and 10 otherwise. Also, for argument base 0 only, underscore characters are permitted as defined by the Go syntax for integer literals.

The bitSize argument specifies the integer type that the result must fit into. Bit sizes 0, 8, 16, 32, and 64 correspond to int, int8, int16, int32, and int64. If bitSize is below 0 or above 64, an error is returned.

The errors that ParseInt returns have concrete type *NumError and include err.Num = s. If s is empty or contains invalid base62Alphabet, err.Err = ErrSyntax and the returned value is 0; if the value corresponding to s cannot be represented by a signed integer of the given size, err.Err = ErrRange and the returned value is the maximum magnitude integer of the appropriate bitSize and sign.

func ParseUint

func ParseUint(s string, base int, bitSize int) (uint64, error)

func SecondKey

func SecondKey() int64

func StandardDeviation

func StandardDeviation[S ~[]T, T constraintsi.Number](data S, isSample bool) float64

func ValidateKey

func ValidateKey(key, secretKey int64) float64

func ValidateSecondKey

func ValidateSecondKey(key int64) float64

func Variance

func Variance[S ~[]T, T constraintsi.Number](data S, isSample bool) float64

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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