mirror of
https://github.com/luxfi/math.git
synced 2026-09-24 00:25:16 +00:00
1e3e11b1e2ef8cd695855bf8d650e87bb61e6bce
typescript 7.0.2 is the native compiler and exports no JavaScript API. next 16.0.1 does not recognize it as installed and runs an unsolicited `pnpm add -D typescript` mid-build, so a bare 7 pin is out: 7.0.2 comes in aliased as tsgo and does the typechecking while typescript stays on the 6 line, which next reads cleanly. docs/ reports the same 4 diagnostics under both compilers, once the two side-effect CSS imports get the ambient declarations TS7 now demands. The lockfile is new; the package already declared pnpm, and npm cannot resolve fumadocs-mdx against next 16. Co-authored-by: Hanzo Dev <[email protected]>
Lux Math Library
A comprehensive mathematical utilities library for the Lux ecosystem.
Features
- Big integer utilities:
HexOrDecimal256,ParseBig256,U256,BigPowetc. - 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.
Languages
Go
100%