Idle games are the rare games that run out of numbers. A balance can pass
a billion in its first hour, and some games are built to go far past
10308. How the game stores it decides where it stops, and what
it quietly loses on the way. Here are six ways to hold a number, and where
each one gives out.
Whole numbers32-bit integerExact to 2,147,483,647; one more wraps round to minus.
Details ↓
Whole numbers64-bit integerExact to 9.2 quintillion, and not one coin more.
Details ↓
Floating pointFloatUp to 3.4 × 10³⁸, but only about seven digits of it.
Details ↓
Floating pointDoubleAbout 16 digits, up to 1.8 × 10³⁰⁸: Antimatter Dimensions' Infinity.
Details ↓
Past a doubleMantissa and exponentA double's digits, times 10 to any power up to 9 quadrillion.
Details ↓
Past a doubleTowers of exponents10 to the 10 to the 10…: how many times to take the log, stored too.
Details ↓
Each scoreboard shows the moment its type gives out: wrapping round,
rounding a coin away, or running into Infinity. The last two keep going by
storing the exponent, or a whole tower of them, as numbers of their own.
Whole numbers
Every value exact, down to the last coin, up to a hard ceiling.
32-bit integer
Also called int, Int32
A whole number in 32 bits: exact, fast, and finished at 2,147,483,647. One more and it wraps around to −2,147,483,648, unless the code checks first.
Largest
2,147,483,647
Digits kept
Every whole number
Size
4 bytes
Good for
Counts that stay small: levels, items, kills
64-bit integer
Also called long, Int64
Twice the bits: every whole number up to about 9.2 quintillion, exactly. Plenty for a game that grows by adding, but anything that multiplies gets there fast; the eight-tier chain on Generator chains does in about 15 minutes.
Largest
9,223,372,036,854,775,807
Digits kept
Every whole number
Size
8 bytes
Good for
Money in a game that adds rather than multiplies
Floating point
A handful of significant digits and a power of two to scale them, so the range is enormous but the number of digits is fixed.
Float
Also called single precision, Single
About seven significant digits, scaled by a power of two, up to 3.4 × 10³⁸. Past 16,777,216 not every whole number fits, so adding one coin can do nothing at all.
Largest
3.4 × 10³⁸
Digits kept
About 7
Size
4 bytes
Good for
Positions, short timers, and anything that needs only a few digits
Double
Also called double precision, Number in JavaScript
About sixteen significant digits, up to 1.8 × 10³⁰⁸. It's every number in JavaScript, and the Infinity of Antimatter Dimensions, which sits just under 2¹⁰²⁴, where doubles run out.
Largest
1.8 × 10³⁰⁸
Digits kept
About 16
Size
8 bytes
Good for
Nearly every idle game's money, from day one
Past a double
Libraries that store the exponent as a number of its own, for games whose numbers outgrow the hardware's.
Mantissa and exponent
Also called break_infinity, BigDouble
Keep the leading digits as a double and the power of ten as a number of its own, and the ceiling jumps to 10 to the 9 quadrillion. The digits kept are still a double's sixteen.
Largest
10^(9 × 10¹⁵)
Digits kept
About 16
Size
16 bytes (two numbers)
Good for
Games that mean to pass 10³⁰⁸
Towers of exponents
Also called break_eternity, tetration
Store a sign, a magnitude, and a layer: how many times 10 is raised to the power of it. Numbers become towers like the 10^10^10^(1.2 × 10³⁴) above, up to a tower 1.8 × 10³⁰⁸ tens tall.
Largest
10↑↑(1.8 × 10³⁰⁸)
Digits kept
About 16, at the top of the tower
Size
Three numbers: sign, layer, magnitude
Good for
Games about growth itself, with layers on layers of resets
The maths
Digits are logarithms
digits in n = ⌊log10 n⌋ + 1
So 2,147,483,647 has 10 digits, the largest double has 309, and
break_infinity's ceiling has nine quadrillion. Idle games are easiest
to think about in logs: an income that doubles every minute adds about
0.3 to its log each minute, so it gains a digit every three and a third
minutes.
Floating point: digits and a scale
value = significand × 2exponent
A float keeps 24 binary digits of significand (24 × log10 2
≈ 7.2 decimal digits) and a double 53 (≈ 16). Between neighbouring
values there's a gap of 2exponent − 23 for a float. Below
16,777,216 = 224 the gap is at most 1, so every whole number
fits; from there it's 2, so 16,777,216 + 1 lands halfway between two
values and rounds to the even one, back where it started.
Mantissa and exponent
(a × 10m) × (b × 10n) = (a × b) × 10m + n · (a × 10m)k = ak × 10m × k
Store the exponent as its own number and multiplying is adding
exponents, and powers are multiplying them, so overflow waits until the
exponent itself runs out: break_infinity stops it at 9 × 1015.
Adding is the hard part: the exponents have to be lined up first, and
if they differ by more than about 16 the smaller number vanishes, the
same limit a double has. More range never means more digits.
Towers
10↑↑3 = 101010
Past even that, break_eternity counts how many times 10 is raised to a
power, its layer, and keeps a double for the top of the tower. That's
tetration, the step after exponentiation, as exponentiation is the step
after multiplying.
One coin a second
Add one coin every second for an hour, to a balance held in a float and
in a double. Pick a starting balance.
Balance1,000,000+ 1 coin a second, for an hour
Both keep every coin: the gaps between the values they can hold are no bigger than a coin.
Float 3,600 of 3,600Steps of 1/16 of a coin
Double 3,600 of 3,600Steps of 1/8,589,934,592 of a coin
Kept: 100% in a float, 100% in a double.
Balance16,777,000+ 1 coin a second, for an hour
The float keeps 216 coins, until the balance reaches 16,777,216 (2²⁴), where its steps grow to 2 coins and every +1 rounds back. The double keeps it all.
Float 216 of 3,600Steps of 1 coin
Double 3,600 of 3,600Steps of 1/536,870,912 of a coin
Kept: 6.0% in a float, 100% in a double.
Balance100,000,000+ 1 coin a second, for an hour
The float can only step 8 coins at a time here, so each +1 rounds back and the whole hour is lost. The double keeps it all.
Float 0 of 3,600Steps of 8 coins
Double 3,600 of 3,600Steps of 1/67,108,864 of a coin
Kept: 0.0% in a float, 100% in a double.
Balance1,000,000,000,000,000+ 1 coin a second, for an hour
The float can only step 67,108,864 coins at a time here, so each +1 rounds back and the whole hour is lost. The double keeps it all.
Float 0 of 3,600Steps of 67,108,864 coins
Double 3,600 of 3,600Steps of 1/8 of a coin
Kept: 0.0% in a float, 100% in a double.
Balance9,007,199,254,740,000+ 1 coin a second, for an hour
The double keeps 992 coins, until the balance reaches 9,007,199,254,740,992 (2⁵³), where its steps grow to 2 coins: the float's wall again, 29 bits further on.
Float 0 of 3,600Steps of 1,073,741,824 coins
Double 992 of 3,600Steps of 1 coin
Kept: 0.0% in a float, 28% in a double.
Balance10,000,000,000,000,000+ 1 coin a second, for an hour
Now the double's steps are 2 coins, so it loses the hour too: more range wouldn't help, only more digits.
Float 0 of 3,600Steps of 1,073,741,824 coins
Double 0 of 3,600Steps of 2 coins
Kept: 0.0% in a float, 0.0% in a double.
Nothing crashes and nothing warns: the small income simply stops
counting. In a real game the culprit is usually a tiny per-frame amount
added to a big balance sixty times a second, or a weak early generator
still paying into a late-game total. Adding up the small amounts on their
own first, and paying them in once they've grown, loses far less.
Out of room
Vault generated with PixelLab.
A number type is a vault with a fixed size, and each kind fails in
its own way when it fills. Integers wrap round, which is why a
checked add (checked in C#) or a clamp belongs on every
balance. Floats overflow to Infinity, then turn the maths into
Infinity and NaN. And long before either, floating point starts
rounding small amounts away, as above.
Antimatter Dimensions turned the vault's door into the game: reaching
the largest double opens its first prestige layer, called Infinity, and
past it the game's numbers run on break_infinity.js.
Writing them down
The same values in four common notations, to three significant figures
(the logarithm to two decimal places).
Antimatter Dimensions lets players pick from these and more.
Notation
1,234
12,345,678
1.234 × 1015
1.234 × 1040
1.797 × 10308
Standard
1.23 K
12.3 M
1.23 Qa
12.3 DDc
–
Scientific
1.23e3
1.23e7
1.23e15
1.23e40
1.80e308
Engineering
1.23e3
12.3e6
1.23e15
12.3e39
180e306
Logarithm
e3.09
e7.09
e15.09
e40.09
e308.25
Standard's short names here stop at duodecillion (1039); longer
ones exist, but by then few players can read them.