godecimal

package
v1.0.132 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs added in v1.0.52

func Abs(x float64) float64

Abs 取绝对值

func Ceil added in v1.0.52

func Ceil(x float64) float64

Ceil 向上取整

func Float64Add added in v1.0.52

func Float64Add(f1, f2 float64) float64

Float64Add 加 (f1+f2)

func Float64Mul added in v1.0.52

func Float64Mul(f1, f2 float64) float64

Float64Mul 乘 (f1*f2)

func Float64Quo added in v1.0.52

func Float64Quo(f1, f2 float64) float64

Float64Quo 除 (f1/f2)

func Float64Sub added in v1.0.52

func Float64Sub(f1, f2 float64) float64

Float64Sub 减 (f1-f2)

func Floor added in v1.0.52

func Floor(x float64) float64

Floor 向下取整

func Max added in v1.0.52

func Max(x, y float64) float64

Max 取较大值

func Min added in v1.0.52

func Min(x, y float64) float64

Min 取较小值

func Round added in v1.0.44

func Round(x float64) float64

Round 就近取整

func RoundPoint added in v1.0.52

func RoundPoint(x float64) float64

RoundPoint 就近取整并保留小数点

Types

type DFloat added in v1.0.52

type DFloat struct {
	FValue float64
	Point  int
}

func (*DFloat) Scan added in v1.0.52

func (f *DFloat) Scan(value interface{}) error

Scan 方法实现了 sql.Scanner 接口

func (DFloat) Value added in v1.0.52

func (f DFloat) Value() (driver.Value, error)

Value 实现 driver.Valuer 接口,Value 返回 json value

type Decimal

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

func New added in v1.0.52

func New() Decimal

func NewFloat added in v1.0.52

func NewFloat(f float64) Decimal

NewFloat 从浮点数创建

func NewInt added in v1.0.52

func NewInt(i int64) Decimal

NewInt 从整数创建

func NewInterface added in v1.0.72

func NewInterface(value interface{}) Decimal

NewInterface 创建

func NewString added in v1.0.52

func NewString(s string) Decimal

NewString 从字符串创建

func NewUint added in v1.0.52

func NewUint(i uint64) Decimal

NewUint 从无符合整数创建

func (Decimal) Add added in v1.0.52

func (d Decimal) Add(d2 Decimal) Decimal

Add 加 (d+d2)

func (Decimal) AddFloat added in v1.0.52

func (d Decimal) AddFloat(d2 float64) Decimal

AddFloat 加

func (Decimal) AddInt added in v1.0.52

func (d Decimal) AddInt(d2 int64) Decimal

AddInt 加

func (Decimal) AddString added in v1.0.52

func (d Decimal) AddString(d2 string) Decimal

AddString 加

func (Decimal) Float64 added in v1.0.52

func (d Decimal) Float64() float64

Float64 输出 float64

func (Decimal) Float64Point added in v1.0.52

func (d Decimal) Float64Point(p int) float64

Float64Point 输出float64带小数点

func (Decimal) Float64PointAdaptive added in v1.0.52

func (d Decimal) Float64PointAdaptive(maxP int) float64

Float64PointAdaptive 输出float64带小数点(自适应)

func (Decimal) Int64 added in v1.0.52

func (d Decimal) Int64() int64

Int64 输出 int64

func (Decimal) IsInteger added in v1.0.52

func (d Decimal) IsInteger(d2 float64) bool

IsInteger 是否为整数

func (Decimal) MoneyFloat64 added in v1.0.52

func (d Decimal) MoneyFloat64() float64

MoneyFloat64 货币 float64

func (Decimal) Mul added in v1.0.52

func (d Decimal) Mul(d2 Decimal) Decimal

Mul 乘 (d*d2)

func (Decimal) MulFloat added in v1.0.52

func (d Decimal) MulFloat(d2 float64) Decimal

MulFloat 乘

func (Decimal) MulInt added in v1.0.52

func (d Decimal) MulInt(d2 int64) Decimal

MulInt 乘

func (Decimal) MulString added in v1.0.52

func (d Decimal) MulString(d2 string) Decimal

MulString 乘

func (Decimal) Quo added in v1.0.52

func (d Decimal) Quo(d2 Decimal) Decimal

Quo 除 (d/d2)

func (Decimal) QuoFloat added in v1.0.52

func (d Decimal) QuoFloat(d2 float64) Decimal

QuoFloat 除

func (Decimal) QuoInt added in v1.0.52

func (d Decimal) QuoInt(d2 int64) Decimal

QuoInt 除

func (Decimal) QuoString added in v1.0.52

func (d Decimal) QuoString(d2 string) Decimal

QuoString 除

func (Decimal) String added in v1.0.52

func (d Decimal) String() string

String 输出 string

func (Decimal) Sub added in v1.0.52

func (d Decimal) Sub(d2 Decimal) Decimal

Sub 减 (d-d2)

func (Decimal) SubFloat added in v1.0.52

func (d Decimal) SubFloat(d2 float64) Decimal

SubFloat 减

func (Decimal) SubInt added in v1.0.52

func (d Decimal) SubInt(d2 int64) Decimal

SubInt 减

func (Decimal) SubString added in v1.0.52

func (d Decimal) SubString(d2 string) Decimal

SubString 减

Jump to

Keyboard shortcuts

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