numeric

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: AGPL-3.0, AGPL-3.0-or-later Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package numeric holds exact decimal values for Float, Currency and Percent fields. Values travel through documents as json.Number so storage and JSON keep their exact decimal text instead of a binary float approximation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Float64

func Float64(v any) (float64, bool)

Float64 converts v to float64 for consumers that only need an approximate value, such as analytics or scripting runtimes without decimal support.

func IsDecimalFieldtype

func IsDecimalFieldtype(fieldtype string) bool

IsDecimalFieldtype reports whether a DocType field type stores an exact decimal.

func Normalize

func Normalize(v any) (any, error)

Normalize returns the canonical json.Number for v, or an error when v is not a decimal. Empty strings normalize to nil so optional fields stay NULL.

func Number

func Number(d decimal.Decimal) json.Number

Number renders d as canonical JSON number text without trailing zeros.

func Parse

func Parse(v any) (decimal.Decimal, bool)

Parse converts a document, request or driver value into an exact decimal. float64 inputs use their shortest round-trip text, so a JSON number such as 0.1 becomes exactly 0.1 rather than its binary expansion.

Types

This section is empty.

Jump to

Keyboard shortcuts

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