The numeric module for your application provides high-precision arithmetic operations for handling arbitrarily large numbers that exceed the limits of standard floating-point types.
It implements mantissa-exponent representation for both Go and TypeScript environments.
This module provides:
- Large Number Support: Handle numbers beyond standard 64-bit floating-point precision
- Cross-Platform: Identical API and behavior in both Go and TypeScript
- Performance Optimized: Pool-based memory management and efficient algorithms
- Comprehensive Operations: Full arithmetic, comparison, and formatting capabilities
- Multiple Formats: Standard, scientific, engineering, and English notation
- Mantissa-exponent representation for arbitrary precision
- Support for numbers beyond IEEE 754 limits
- Consistent behavior across platforms
- Complete arithmetic operations (add, subtract, multiply, divide, power)
- Comparison operations (equals, greater than, less than)
- Mathematical functions (absolute value, sign, normalization)
- Format conversions (string, scientific notation, engineering notation)
- Object pooling in TypeScript for memory efficiency
- Zero-allocation utilities where possible
- Optimized for common mathematical operations
app/util/numeric/- Core Go implementationNumericstruct with mantissa/exponent fields- Arithmetic and comparison operations
- String formatting and parsing
- JSON marshaling/unmarshaling support
client/src/numeric/- Full-featured TypeScript class- Pool-based memory management
- Complete arithmetic operations
- Multiple formatting options
- Utility functions and constants
import "myapp/app/util/numeric"
// Create numbers
a := numeric.FromString("123456789012345678901234567890")
b := numeric.FromFloat(1.23e15)
// Arithmetic operations
sum := a.Add(b)
product := a.Multiply(b)import { Numeric } from './numeric/numeric';
// Create numbers
const a = new Numeric("123456789012345678901234567890");
const b = Numeric.fromFloat(1.23e15);
// Arithmetic operations
const sum = a.add(b);
const product = a.multiply(b);
// Formatting
console.log(sum.toString()); // Standard notation
console.log(sum.toScientific()); // Scientific notation
console.log(sum.toEngineering()); // Engineering notationNumeric- Main numeric type with mantissa and exponentmantissa- float64 for the significant digitsexponent- int64 for the power of 10
Numeric- Main class with pooling supportMantissaExponent- Interface for mantissa/exponent pairsNumericSource- Union type for input sources (string, number, or MantissaExponent)
No additional configuration required. The module works out of the box with sensible defaults for precision and formatting.
- Repository: https://github.com/kyleu/projectforge/tree/main/module/numeric
- License: CC0 (Public Domain)
- Author: Kyle U (kyle@kyleu.com)
- Project Forge Documentation - Complete documentation