Help us shape the future of Go! Take the 2026 Go Developer Survey

decimal

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package decimal validates exact decimal strings. Financial values are never converted through float64.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Canonical

func Canonical(s string) (string, error)

Canonical normalizes a non-negative plain decimal ("0.0100" -> "0.01"). Signs, exponents, and blanks are rejected.

func Decimals

func Decimals(s string) int

Decimals returns the number of fractional digits of a canonical decimal.

func IsCanonical

func IsCanonical(s string) bool

IsCanonical reports whether s is canonical (no leading/trailing zeros).

func IsZero

func IsZero(s string) bool

IsZero reports whether a canonical decimal is zero.

func Rat

func Rat(s string) (*big.Rat, bool)

Rat parses a canonical decimal exactly.

func SigFigs

func SigFigs(s string) int

SigFigs returns significant digits of a canonical decimal.

func ValidatePerpPrice

func ValidatePerpPrice(px string, szDecimals int) error

ValidatePerpPrice applies Hyperliquid perp price rules: at most 5 significant figures unless integral, and at most 6-szDecimals decimals.

func ValidateSize

func ValidateSize(sz string, szDecimals int) error

ValidateSize checks size precision against szDecimals.

Types

This section is empty.

Jump to

Keyboard shortcuts

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