decimal

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package decimal provides a wrapper around github.com/shopspring/decimal for arbitrary-precision fixed-point decimal numbers.

Index

Constants

This section is empty.

Variables

View Source
var (
	Zero  = decimal.Zero
	One   = decimal.NewFromInt(1)
	Two   = decimal.NewFromInt(2)
	Three = decimal.NewFromInt(3)
	Four  = decimal.NewFromInt(4)
	Five  = decimal.NewFromInt(5)
	Six   = decimal.NewFromInt(6)
	Seven = decimal.NewFromInt(7)
	Eight = decimal.NewFromInt(8)
	Nine  = decimal.NewFromInt(9)
	Ten   = decimal.NewFromInt(10)
)

Common decimal constants.

View Source
var (
	New                      = decimal.New
	NewFromFloat             = decimal.NewFromFloat
	NewFromFloat32           = decimal.NewFromFloat32
	NewFromFloatWithExponent = decimal.NewFromFloatWithExponent
	NewFromInt               = decimal.NewFromInt
	NewFromInt32             = decimal.NewFromInt32
	NewFromUint64            = decimal.NewFromUint64
	NewFromBigInt            = decimal.NewFromBigInt
	NewFromBigRat            = decimal.NewFromBigRat
	NewFromString            = decimal.NewFromString
	NewFromFormattedString   = decimal.NewFromFormattedString
	RequireFromString        = decimal.RequireFromString
)

Constructors for creating Decimal values.

View Source
var (
	Max         = decimal.Max
	Min         = decimal.Min
	Sum         = decimal.Sum
	Avg         = decimal.Avg
	RescalePair = decimal.RescalePair
)

Utility functions for decimal operations.

Functions

This section is empty.

Types

type Decimal

type Decimal = decimal.Decimal

Decimal is an alias for decimal.Decimal.

func MustFromAny

func MustFromAny(v any) Decimal

MustFromAny is like NewFromAny but panics if the value cannot be converted.

func NewFromAny

func NewFromAny(v any) (Decimal, error)

NewFromAny creates a Decimal from an arbitrary value. Supported types: Decimal, *Decimal, int/int8/int16/int32/int64, uint/uint8/uint16/uint32/uint64, float32, float64, string, []byte, bool (true=1, false=0), and fmt.Stringer. Returns an error for unsupported types.

Jump to

Keyboard shortcuts

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