decimals

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package decimals reads values as parse's exact decimals where a document member or a SQLite value holds one, and encodes a decimal as a key whose bytes order as the decimals do. The filter package reads document members through Member; parse's SQLite functions (parsesqlite) are Value and Key.

Index

Constants

View Source
const (
	SQLiteValueFunc = "parse_decimal"
	SQLiteKeyFunc   = "parse_decimal_key"
)

The SQLite functions parse's dialect calls and parsesqlite registers: Value and Key of one argument.

View Source
const MaxMemberLength = core.MaxDecimalDigits

MaxMemberLength bounds a decimal member string's length; within it, its digits are within core.MaxDecimalDigits.

View Source
const PlainRegex = `^-?(0|[1-9][0-9]*)([.][0-9]+)?$`

PlainRegex is a decimal in plain notation, the text a decimal member's string holds (shopspring's JSON form): no exponent, so no cast of a member can overflow.

Variables

This section is empty.

Functions

func Key

func Key(text string) []byte

Key encodes canonical decimal text (core.DecimalText) as bytes whose bytewise order is the decimals' numeric order; equal decimals have equal keys. A nonzero magnitude is 0.d₁d₂…dₙ × 10^e with d₁ and dₙ nonzero: its key is the sign byte, e biased to two big-endian bytes, then the digits. For a negative the exponent and digits are complemented and a terminator follows, so a greater magnitude orders lower. text must be canonical.

func Member

func Member(v any) (string, bool)

Member is the canonical text (core.DecimalText) of a decoded JSON document member read as a decimal: a JSON number (json.Number, or a Go number encoding/json decoded) within core.MaxDecimalDigits digits, or a string in plain notation of at most MaxMemberLength characters. ok is false for any other member.

func Value

func Value(v any) (string, bool)

Value is the canonical text of a SQLite value read as a decimal, ok false when it holds none:

  • INTEGER (int64): its digits;
  • REAL (float64): its shortest decimal form, as core.DecimalText reads a float64;
  • TEXT (string or []byte): a JSON number literal, the text a decimal column holds exactly; or a JSON string literal, a document member as the `->` operator returns it, read as Member reads a string.

A JSON literal of another kind (null, true, an object) is none.

Types

This section is empty.

Jump to

Keyboard shortcuts

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