zeekay 7c7f671c2f add native CI; refresh go.sum against the declared requirements
go.mod asked for ids v1.3.2 and crypto v1.20.2 while go.sum still carried
v1.2.9 and v1.19.0, so the module did not build. Retidied the root and the
nested bit/ and safe/ modules; bit/ was additionally missing the luxfi/geth
requirement that its compress test imports.

The CI test command covers all four modules — go test ./... stops at a nested
module boundary and would otherwise skip bit/, big/ and safe/ entirely.
2026-08-21 00:11:23 -07:00
2026-06-28 20:55:56 -07:00
2026-08-20 20:12:58 -07:00
2026-08-20 20:12:58 -07:00
2026-02-14 05:26:21 -08:00
2026-06-28 20:55:57 -07:00

math

Lux Math Library

A comprehensive mathematical utilities library for the Lux ecosystem.

Features

  • Big integer utilities: HexOrDecimal256, ParseBig256, U256, BigPow etc.
  • Safe arithmetic: Overflow-checked SafeAdd, SafeSub, SafeMul
  • Bit operations: XOR, AND, compression utilities
  • Set operations: Efficient set implementations including bit sets
  • Data structures: Linked lists, hash maps, heaps
  • Averagers: Time-windowed averaging utilities

Installation

go get github.com/luxfi/math

Package Structure

Package Description
github.com/luxfi/math Root package with re-exports for backwards compatibility
github.com/luxfi/math/big Big integer utilities (HexOrDecimal256, U256, parsing)
github.com/luxfi/math/safe Overflow-safe arithmetic operations
github.com/luxfi/math/bit Bit manipulation utilities
github.com/luxfi/math/set Set data structures
github.com/luxfi/math/linked Linked data structures
github.com/luxfi/math/heap Heap implementations

Usage

// Import root package (re-exports from subpackages)
import "github.com/luxfi/math"

// Or import specific subpackages directly
import (
    "github.com/luxfi/math/big"
    "github.com/luxfi/math/safe"
    "github.com/luxfi/math/set"
)

Big Integer Operations

import "github.com/luxfi/math/big"

// Parse hex or decimal
val, _ := big.ParseBig256("0x1234")

// 256-bit unsigned operations
result := big.U256(someInt)

// Power operation
power := big.BigPow(2, 256)

Safe Arithmetic

import "github.com/luxfi/math/safe"

// Returns (result, overflow bool)
sum, overflow := safe.SafeAdd(a, b)
product, overflow := safe.SafeMul(x, y)

// Returns (result, error)
sum, err := safe.Add64(a, b)

License

See the LICENSE file for licensing terms.

S
Description
Mathematical utilities library for the Lux ecosystem
Readme BSD-3-Clause
1.9 MiB
Languages
Go 100%