decimal

package
v0.0.43 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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 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 DecimalV2

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

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

func New1

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

func (*DecimalV2) Add

func (d *DecimalV2) Add(v DecimalV2) DecimalV2

func (*DecimalV2) Dec

func (d *DecimalV2) Dec() string

func (*DecimalV2) DecInt

func (d *DecimalV2) DecInt() uint64

func (*DecimalV2) Multi

func (d *DecimalV2) Multi(v DecimalV2)

func (*DecimalV2) SetDec

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

func (*DecimalV2) SetDecInt

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

func (DecimalV2) String

func (d DecimalV2) String() string

type DecimalV3

type DecimalV3 string

example:"123456789.987654321"

type DecimalV4

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

func New3

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

func New3FromStr

func New3FromStr(str string) (DecimalV4, error)

func (*DecimalV4) Add

func (x *DecimalV4) Add(v DecimalV4) *DecimalV4

func (*DecimalV4) Compose

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

func (*DecimalV4) Decompose

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

func (*DecimalV4) Div

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

func (*DecimalV4) DivInt

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

func (*DecimalV4) Float

func (x *DecimalV4) Float() float64

func (*DecimalV4) Mul

func (x *DecimalV4) Mul(v DecimalV4) *DecimalV4

func (*DecimalV4) Scan

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

func (DecimalV4) String

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

func (*DecimalV4) Sub

func (x *DecimalV4) Sub(v DecimalV4) *DecimalV4

func (DecimalV4) Value

func (x DecimalV4) 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