number

package
v0.0.0-...-1f4ee57 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatFloat

func FormatFloat(num float64) string

func GenKey

func GenKey() int64

func IsNumeric

func IsNumeric(val interface{}) bool

is_numeric()

func Validation

func Validation(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

type Decimal

type Decimal struct {
	// contains filtered or unexported fields
}

func (*Decimal) Compose

func (d *Decimal) Compose(form byte, negative bool, coefficient []byte, exponent int32) error

func (*Decimal) Decompose

func (d *Decimal) Decompose(buf []byte) (form byte, negative bool, coefficient []byte, exponent int32)

func (*Decimal) String

func (d *Decimal) String() string

type Decimal1

type Decimal1 struct {
	Int uint64
	// contains filtered or unexported fields
}

放弃,省空间,但计算时间浪费,来回不停转字符串

func New1

func New1(Dec string) (dec Decimal1, err error)

func (*Decimal1) Add

func (d *Decimal1) Add(v Decimal1) Decimal1

func (*Decimal1) Dec

func (d *Decimal1) Dec() string

func (*Decimal1) DecInt

func (d *Decimal1) DecInt() uint64

func (*Decimal1) Multi

func (d *Decimal1) Multi(v Decimal1)

func (*Decimal1) SetDec

func (d *Decimal1) SetDec(dec string) error

func (*Decimal1) SetDecInt

func (d *Decimal1) SetDecInt(dec uint64) error

func (Decimal1) String

func (d Decimal1) String() string

type Decimal11

type Decimal11 struct {
	Int uint64
	// contains filtered or unexported fields
}

func New11

func New11(Dec string, eff int) (dec *Decimal11, err error)

func (*Decimal11) Add

func (x *Decimal11) Add(v *Decimal11) *Decimal11

func (*Decimal11) String

func (x *Decimal11) String() string

type Decimal3

type Decimal3 struct {
	// contains filtered or unexported fields
}

func New3

func New3(mant uint64, exp int, neg bool) *Decimal3

func New3FromStr

func New3FromStr(str string) (Decimal3, error)

func (*Decimal3) Add

func (x *Decimal3) Add(v Decimal3) *Decimal3

func (*Decimal3) Compose

func (x *Decimal3) Compose(form byte, negative bool, mant []byte, exponent int32) error

func (*Decimal3) Decompose

func (x *Decimal3) Decompose(buf []byte) (form byte, negative bool, mant []byte, exponent int32)

func (*Decimal3) Div

func (x *Decimal3) Div(v Decimal3, mode RoundingMode) *Decimal3

func (*Decimal3) DivInt

func (x *Decimal3) DivInt(v int, mode RoundingMode) *Decimal3

func (*Decimal3) Float

func (x *Decimal3) Float() float64

func (*Decimal3) Mul

func (x *Decimal3) Mul(v Decimal3) *Decimal3

func (*Decimal3) Scan

func (x *Decimal3) Scan(raw interface{}) error

func (Decimal3) String

func (x Decimal3) String() string
func (x *Decimal3) Div2(v Decimal3) *Decimal3 {
	f1:=big.NewFloat(x.Float())
	f2:=big.NewFloat(v.Float())
	f3,_:=f1.Quo(f1,f2).Float64()
}

func (*Decimal3) Sub

func (x *Decimal3) Sub(v Decimal3) *Decimal3

func (Decimal3) Value

func (x Decimal3) Value() (driver.Value, error)

type RoundingMode

type RoundingMode uint8
const (
	UP RoundingMode = iota
	DOWN
	HALFUP
)

Jump to

Keyboard shortcuts

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