Numerics

TypeScript and Golang implementations for managing large numbers.

Technology

The numeric module for Project Forge 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.

Overview

This module provides:

Key Features

Precision

Operations

Performance

Package Structure

Go Implementation

TypeScript Implementation

Usage Examples

Go

 1
2
3
4
5
6
7
8
9
10
11
12
13
14
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)

// Formatting
fmt.Println(sum.String()) // Standard notation
fmt.Println(sum.Scientific()) // Scientific notation
fmt.Println(sum.Engineering()) // Engineering notation

TypeScript

 1
2
3
4
5
6
7
8
9
10
11
12
13
14
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 notation

Core Types

Go Types

TypeScript Types

Configuration

No additional configuration required. The module works out of the box with sensible defaults for precision and formatting.

Source Code

See Also