decimal

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 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 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 Decimal2

type Decimal2 string

example:"123456789.987654321"

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