decimal

package module
v0.0.0-...-29fd699 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2024 License: BSL-1.0 Imports: 4 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 {
	Negative bool
	Integer  uint64
	Fraction uint64
	Digits   uint8 // Number of digits in Fraction, must be less or equal to 20, not all values with 20 digits can be represented due to limits of uint64
}

func New

func New[N Number](value N) *Decimal

func NewFromString

func NewFromString(s string) (*Decimal, error)

func NewFromStringFuzzy

func NewFromStringFuzzy(s string) (*Decimal, error)

NewFromStringFuzzy extracts and parses the first number from a string, ignoring any leading or trailing non-numeric characters.

func Zero

func Zero() *Decimal

func (*Decimal) Clone

func (d *Decimal) Clone() *Decimal

func (*Decimal) DivideUint64

func (d *Decimal) DivideUint64(u uint64) *Decimal

func (Decimal) Float64

func (d Decimal) Float64() float64

func (*Decimal) FromFloat64

func (d *Decimal) FromFloat64(f float64)

func (*Decimal) FromString

func (d *Decimal) FromString(s string) error

func (*Decimal) FromStringFuzzy

func (d *Decimal) FromStringFuzzy(s string) error

FromStringFuzzy extracts and parses the first number from a string, ignoring any leading or trailing non-numeric characters.

func (Decimal) MarshalCBOR

func (d Decimal) MarshalCBOR() ([]byte, error)

func (Decimal) MarshalJSON

func (d Decimal) MarshalJSON() ([]byte, error)

func (*Decimal) MultiplyUint64

func (d *Decimal) MultiplyUint64(u uint64) *Decimal

func (*Decimal) Scan

func (d *Decimal) Scan(value interface{}) error

func (Decimal) String

func (d Decimal) String() string

func (*Decimal) ToDigits

func (d *Decimal) ToDigits(digits uint8) *Decimal

func (*Decimal) UnmarshalCBOR

func (d *Decimal) UnmarshalCBOR(data []byte) error

func (*Decimal) UnmarshalJSON

func (d *Decimal) UnmarshalJSON(data []byte) error

func (Decimal) Value

func (d Decimal) Value() (driver.Value, error)

type Number

type Number interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~int | ~int8 | ~int16 | ~int32 | ~int64 | ~float32 | ~float64
}

Jump to

Keyboard shortcuts

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