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.

Examples:
1/3 + 1/6 = 1/2 (exactly)
0.#3 * 3 = 1 (repeating decimal)
[1.4, 1.6] * [2.9, 3.1] = [4.06, 4.96] (intervals)
🧮 Try RatCalc 📚 Library Showcase 🌳 Explore RatTree 💻 View on GitHub
calc.ratmath.com

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