Ratmath

Exact Rational Arithmetic & Interval Arithmetic Library

Ratmath is a powerful JavaScript library for exact rational arithmetic and interval arithmetic. Unlike floating-point numbers, Ratmath maintains perfect precision for fractional calculations, making it ideal for financial calculations, scientific computing, and any application where exact results matter.

🔢 Exact Arithmetic

No rounding errors or precision loss. Every calculation is mathematically exact using rational numbers.

📊 Interval Arithmetic

Work with ranges and uncertainties. Perfect for error analysis and approximate calculations.

🎯 Rich Number Formats

Support for fractions, decimals, repeating decimals, mixed numbers, and scientific notation.

⚡ High Performance

Built on BigInt for arbitrary precision while maintaining excellent performance.

🌳 Interactive Visualizations

Explore the Stern-Brocot tree to understand the relationships between rational numbers and continued fractions.

📐 Continued Fractions

Full support for continued fraction notation, convergents, and optimal rational approximations.

RatCalc is JavaScript with exact arithmetic:
R`1/3 + 1/6` → 1/2 (exactly)
R`0.#3 * 3` → 1 (repeating decimal)
R`(1.4:1.6) * (2.9:3.1)` → 203/50:124/25 (intervals)
[1, 2, 3].map(n => R`1/${n}`) → [1, 1/2, 1/3]
🧮 Try RatCalc 📚 Library Showcase 🌳 Explore RatTree 💻 View on GitHub
calc.ratmath.com

Created by James Taylor with the help of Novix and Zeddy! 🎉