ints

package
v0.4.13 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2025 License: Unlicense Imports: 4 Imported by: 0

Documentation

Overview

Package ints is an optimised encoder for decimal numbers in ASCII format, that simplifies and accelerates encoding and decoding decimal strings. It is faster than strconv in part because it uses a base of 10000 and a lookup table.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type T

type T struct {
	N uint64
}

T is an integer with a fast codec to decimal ASCII.

func New

func New[V constraints.Integer](n V) *T

func (*T) Int64

func (n *T) Int64() int64

Int64 returns an int64 from the base number (may cause truncation)

func (*T) Marshal

func (n *T) Marshal(dst []byte) (b []byte)

Marshal the int.T into a byte string.

func (*T) Uint16

func (n *T) Uint16() uint16

Uint16 returns an uint16 from the base number (may cause truncation)

func (*T) Uint64

func (n *T) Uint64() uint64

Uint64 returns the int.T as a uint64 (the base type)

func (*T) Unmarshal

func (n *T) Unmarshal(b []byte) (r []byte, err error)

Unmarshal reads a string, which must be a positive integer no larger than math.MaxUint64, skipping any non-numeric content before it.

Note that leading zeros are not considered valid, but basically no such thing as machine generated JSON integers with leading zeroes. Until this is disproven, this is the fastest way to read a positive json integer, and a leading zero is decoded as a zero, and the remainder returned.

Directories

Path Synopsis
Package main is a generator for the base10000 (4 digit) encoding of the ints library.
Package main is a generator for the base10000 (4 digit) encoding of the ints library.

Jump to

Keyboard shortcuts

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