Big Number / Arbitrary Precision Calculator

Exact arithmetic on whole numbers and fractions of any size. Type an expression such as 1000!, 2^256 or modpow(7, 10^18, 1000000007) and get every digit, with square roots, π and e to as many as 20,000 decimal places.

Calculator Numbers & Math Updated Oct 3, 2026
How to Use
  1. Type an expression (2^256 is loaded to start) and press Enter or click Evaluate. The result updates as you type; Enter also adds it to the history.
  2. Use + − * / % ^, postfix !, brackets and implicit multiplication such as 2(3+4). Numbers can be decimals (1.5), hex (0xFF) or scientific (1.2e-9).
  3. Call functions by name: gcd lcm mod modpow modinv fact ncr npr fib lucas isprime nextprime isqrt iroot bitlength popcount for whole numbers, and sqrt cbrt root exp with the constants pi and e.
  4. Set Decimal precision (1 to 20,000 places, 50 to start) for fractions that don’t terminate and for roots, exp, π and e.
  5. Read the cards under the result: digits, scientific form, bit length and hex for whole numbers; the exact fraction and whether the decimal terminates for fractions.
  6. Click an example to load it, or a history row to bring it back. Copy puts the full value on the clipboard, without the thousands commas.
Input
places — for division, √, ∛, root, π, e, exp
Result
History
Digits
—
Type
—
Scientific
—
Operations
—

Worked Example

2^256, the starting expression. The result is 115,792,089,237,316,195,423,570,985,008,687,907,853,269,984,665,640,564,039,457,584,007,913,129,639,936: 78 digits, about 1.15792 × 1077, with a bit length of 257. It is the number of possible 256-bit keys, or SHA-256 hash values.

A modular power. modpow(7, 10^18, 1000000007) = 259616729. Square-and-multiply works through the 60 bits of 1018, squaring once per bit, so the answer needs about 60 steps instead of 1018 multiplications, and no number ever grows past (109 + 7)².

The common mistake: trusting ordinary arithmetic past 253. In JavaScript, and in any language that uses 64-bit floating point, 2^53 + 1 is stored as 9,007,199,254,740,992, because whole numbers above 253 are no longer all representable. The exact answer, which this calculator gives, is 9,007,199,254,740,993.

Show Work

Type an expression such as 2^256 or 100! to see each operation worked out.

Formulas

Exact fractions
a/b + c/d = (ad + bc) ÷ bd, then divide both by their gcd
Square-and-multiply
for each bit of e: if 1, r = r·a mod m; a = a² mod m
Integer square root (Newton)
x ← (x + ⌊n ÷ x⌋) ÷ 2 until x stops falling
Machin’s formula
π = 16·arctan(1/5) − 4·arctan(1/239)
Fibonacci by fast doubling
F(2k) = F(k)·(2F(k+1) − F(k)), F(2k+1) = F(k)² + F(k+1)²
Miller–Rabin
n − 1 = 2ʳ·d; pass if aᵈ ≡ 1 or a^(2ˢ·d) ≡ −1 (mod n) for some s < r

Big Numbers by Hand

John Machin used his arctangent formula to compute π to 100 decimal places in 1706. In 1876 Édouard Lucas proved that 2127 − 1, a 39-digit number, is prime, working by hand; it stayed the largest known prime for 75 years, until 1951.

The primality test used here comes from Gary Miller, who gave a deterministic version in 1976 that depends on the unproven generalised Riemann hypothesis, and Michael Rabin, who turned it into a random test in 1980. Testing a fixed set of bases, as this calculator does, is proven correct up to a known bound with no hypothesis needed.

About This Tool

This calculator keeps every number as an exact fraction of two whole numbers of any length, so nothing is rounded until it is shown, and it adds the number theory that ordinary calculators lack: modular powers and inverses, gcd and lcm, primality, binomial coefficients and Fibonacci numbers. The focused calculators explain one operation in more depth: the Factorial Calculator adds trailing zeros and Stirling’s approximation, the Exponent Calculator solves for an unknown exponent with the steps, and the Basic Calculator shows the order of operations. Use this one when you need every digit of a large result.

Everything runs in your browser; nothing is uploaded.

Related tools: Factorial Calculator, Exponent Calculator, Basic Calculator, and Prime Number Checker.

Frequently Asked Questions

Why does 0.1 + 0.2 give exactly 0.3 here?

Every number is kept as a fraction of two whole numbers, so 0.1 is stored as 1/10 and the sum is exactly 3/10. Ordinary calculators and programming languages use binary floating point, which cannot store 0.1 exactly; there 0.1 + 0.2 comes out as 0.30000000000000004, because the nearest double to the sum is 0.3000000000000000444089209850062616169452667236328125.

How do / and % work?

Division is exact, not integer division: 10/4 is the fraction 5/2, shown as 2.5, and 100/7 is 14.285714… with the repeating decimal to your chosen precision. % and mod() both give the remainder that is never negative, so −7 % 3 = 2 and 100 % 7 = 2. For the whole-number quotient, use (100 − 100 % 7) / 7 = 14.

Is isprime exact?

It runs the Miller–Rabin test with the 13 prime bases from 2 to 41, which is proven correct for every number below 3.3 × 10²⁴. It returns 1 for prime and 0 for composite. With only the bases up to 37 the test would be fooled by the composite 318,665,857,834,031,151,167,461. Above 3.3 × 10²⁴, such as for the 39-digit 2¹²⁷ − 1, a 1 means a very strong probable prime rather than a proof.

How big can the numbers get?

A power may have up to about 12 million bits (roughly 3.6 million digits), a factorial up to 1,000,000! and a Fibonacci index up to 4,000,000; decimals go to 20,000 places. For scale, 2^256 has 78 digits, 1000! has 2,568 and fib(1000) has 209.

Are the digits of √2, π and e rounded?

They are cut off, not rounded, so every digit shown is correct. π to 4 places shows 3.1415, although rounding would give 3.1416. Square roots use Newton’s method on whole numbers, π uses Machin’s formula with 12 extra guard digits, and e and exp() use the Taylor series with 15 guard digits. A result built from an approximation, such as sqrt(2) × sqrt(2), is marked as approximate.

How do I use the Big Number / Arbitrary Precision Calculator?

Simply type your numbers and read the result, which refreshes the instant you change something. There is nothing to submit and nothing to wait for.

Do I need to install or sign up for anything?

Not at all — it runs in the browser with nothing to install and no account. After it loads once, it even works without an internet connection.

Is my information private?

Yes. Everything happens in your browser. Nothing you type is sent to a server or saved anywhere.

Common Use Cases

Modular arithmetic

modpow(7, 10^18, 1000000007) = 259616729, found with 60 squarings instead of 10¹⁸ multiplications.

Combinatorics

ncr(1000, 500), the number of ways to choose 500 of 1,000, written out in all 300 digits.

Exact fractions

1/3 + 1/6 is exactly 1/2, with no 0.49999… from rounding.

Prime hunting

nextprime(10^50) finds the first prime above 10⁵⁰, which is 10⁵⁰ + 151.

Many digits of a constant

√2, π or e to 20,000 decimal places, ready to copy.

Last updated: