number

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecimalPlaces added in v1.5.1

func DecimalPlaces(value float64, prec int) float64

func DecimalPlacesRound added in v1.5.1

func DecimalPlacesRound(value float64, rank int) float64

四舍五入

func FormatFloat

func FormatFloat(num float64) string

func FormatInt

func FormatInt(num, base int64) string

func GenKey

func GenKey(key int64) int64

func IsNumeric

func IsNumeric(val interface{}) bool

is_numeric()

func ParseInt

func ParseInt(str string, base float64) (int64, error)

func SecondKey added in v1.5.1

func SecondKey() int64

func ToBytes

func ToBytes[T constraints.Number](t T) []byte

func ValidateKey added in v1.5.1

func ValidateKey(key, secretKey int64) float64

func ValidateSecondKey added in v1.5.1

func ValidateSecondKey(key int64) float64

func ViewBin

func ViewBin(v interface{})

Sizeof函数返回的大小只包括数据结构中固定的部分,例如字符串对应结构体中的指针和字符串长度部分,但是并不包含指针指向的字符串的内容。Go语言中非聚合类型通常有一个固定的大小,尽管在不同工具链下生成的实际大小可能会有所不同。考虑到可移植性,引用类型或包含引用类型的大小在32位平台上是4个字节,在64位平台上是8个字节。

计算机在加载和保存数据时,如果内存地址合理地对齐的将会更有效率。例如2字节大小的int16类型的变量地址应该是偶数,一个4字节大小的rune类型变量的地址应该是4的倍数,一个8字节大小的float64、uint64或64-bit指针类型变量的地址应该是8字节对齐的。但是对于再大的地址对齐倍数则是不需要的,即使是complex128等较大的数据类型最多也只是8字节对齐。

由于地址对齐这个因素,一个聚合类型(结构体或数组)的大小至少是所有字段或元素大小的总和,或者更大因为可能存在内存空洞。 1字节(byte)=8位(bit) 在16位系统中,1字(word)=2字节(byte)=16位(bit) 在32位系统中,1字(word)=4字节(byte)=32位(bit) 在64位系统中,1字(word)=8字节(byte)=64位(bit)

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