Phaser AE

Enormous decimal values

Free packv3.0.0-4Logic

Decimal arithmetic for huge game currencies, prices and production. Values keep forty significant digits and an exponent up to a billion, and never pass through a JavaScript number that would overflow or lose digits.

This is a Free pack. Every phaser.io account can use it in their games.

Released October 14, 2026 · updated October 20, 2026

Enormous decimal values: a screenshot of its demo
A note about these graphics

Expansion packs don't come with graphics. This screenshot is one way of drawing what the pack does, made for its demo: none of the sprites, tiles or backgrounds in it are in the pack.

That's by design. A pack is a game's logic, mechanics and effects, and it works with whatever art you give it. Some packs draw effects, backdrops or 3D scenes of their own, but none carries a game's sprites.

So the look is yours. Make the art on phaser.io, bring your own, or let your agent draw it in code: the same pack can look like anything.

What it does

Ordinary JavaScript numbers lose exact integer precision above about nine quadrillion and overflow to infinity above about 1.8e308. An idle game can pass both long before its endgame. A LargeNumber holds a forty-digit decimal coefficient and an exponent, so a balance of 1.23456789e400 subtracts a price of 9e398 correctly, and 1e1000000 is still just a number.

Values are immutable. compare, add, subtract, multiply, divide, whole-number pow, sqrt, negate, abs and round each return a new value, and those that can lose digits take a rounding mode: half-even (the default), floor, ceil or trunc. That is what keeps an economy honest: a cost can round up and a balance down, so a player can never buy something they cannot quite afford. round takes negative places too, to round to thousands, billions or multiples of 1e400.

Display is part of the pack. format shows a value as compact suffixes, full short-scale names from thousand to vigintillion plus centillion, scientific, engineering or plain digits, at one to forty significant digits, and rolls 999,999,999 at three digits over to 1 B correctly. Input text accepts the same names, so '1.5 nonillion' is a valid value, and toString and toJSON keep every stored digit for saves.

Features

  • Forty significant digits — with exponents from minus a billion to plus a billion.
  • Directed rounding — half-even, floor, ceil and trunc wherever digits can be lost, and rounding to any power of ten.
  • Full arithmetic — add, subtract, multiply, divide, integer powers, square roots and comparison.
  • Readable formatting — compact, named, scientific, engineering and plain, with a chosen number of digits.
  • Named input — text such as '2 centillion', case-insensitive, alongside scientific notation.
  • JSON-safe — canonical decimal text in saves, read back exactly.
  • Explicit failures — division by zero, negative square roots, bad formats and out-of-range exponents throw rather than quietly giving nonsense.

Good for

  • Idle and incremental games, where currency and production climb through hundreds of orders of magnitude.
  • Clicker games with prices in the octillions and upgrades that multiply them.
  • Enormous scores that pass what an ordinary number holds exactly.
  • Scientific-style quantities shown in engineering or scientific notation.

Make it yours

The pack has no options; the choices are per call. Each operation takes its rounding mode, and formatting takes a notation and a number of significant digits. Two different uses: an idle business game that formats every price named at three digits ("12.5 quadrillion") and rounds costs with ceil; and a space game that shows distances in scientific notation and rounds them to the nearest 1e9 for its readout.

A quick look

A balance, a price and the result, formatted and saved:

const balance = game.largeNumbers.largeNumber('1.23456789e400');
const price = game.largeNumbers.largeNumber('9e398');
const after = balance.subtract(price, 'floor');
after.format();                         // '11.45e+399'
game.largeNumbers.largeNumber('2500000000').round(-9); // 2e9 (ties to even)
JSON.stringify(after);                  // canonical decimal string

Works with

  • incremental — idle business ladders and mine pipelines with every price and balance held in these values.
  • save — keeps the JSON text between visits.

Good to know

  • Forty significant digits is a game decimal, not unlimited exact integers; use native BigInt when every digit matters, and do not use it for financial accounting.
  • toNumber() is an approximate conversion for ratios and screen positions; never pass a balance through it.
  • Inputs are limited to 4096 characters, powers to a million either way, and plain display to about 4096 characters.

More Logic packs

Show all →