decimal

package
v0.1.0-alpha.6 Latest Latest
Warning

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

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

Documentation

Overview

Package decimal implements the bounded base-ten pipeline numeric contract.

Index

Constants

View Source
const MaxPrecision = 38

Variables

View Source
var ErrConversion = xerror.New(xerror.KindInvalidInput, "PIPELINE_DECIMAL_CONVERSION", "invalid bounded decimal conversion")

Functions

func ValidateDeclaration

func ValidateDeclaration(precision, scale int) error

Types

type Value

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

Value is immutable; operations allocate a destination and never mutate operands. The zero value represents decimal zero.

func Cast

func Cast(value any) (Value, error)

Cast exposes the already-rounded float's shortest decimal representation.

func From

func From(value any) (Value, error)

From accepts exact decimal tokens and integers. Binary floats require Cast.

func Parse

func Parse(text string) (Value, error)

Parse rejects hostile tokens before coefficient allocation and never rounds input.

func (Value) Cmp

func (v Value) Cmp(other Value) int

func (Value) EstimatedBytes

func (v Value) EstimatedBytes() int64

EstimatedBytes includes coefficient storage as well as the serialized token.

func (Value) Inexact

func (v Value) Inexact() bool

func (Value) MarshalJSON

func (v Value) MarshalJSON() ([]byte, error)

func (Value) Operation

func (v Value) Operation(other Value, operation string) (Value, error)

func (Value) Quantize

func (v Value) Quantize(precision, scale int) (Value, error)

func (Value) Rat

func (v Value) Rat() *big.Rat

Rat is exact and bounded by the decimal exponent contract.

func (Value) Rounded

func (v Value) Rounded() bool

func (Value) String

func (v Value) String() string

Jump to

Keyboard shortcuts

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