Skip to content

Playground

Write BigDecimal.js code and run it right here — it executes in your browser against the actual library build. Big, MC, RoundingMode, BigDecimal, and MathContext are all in scope, along with console.

The last expression is printed automatically; use console.log(...) for scripts. Press Run or Ctrl / + Enter.

Ctrl / ⌘ + Enter

Things to try

  • Change MC(15, ...) to MC(50, ...) and watch 1/3 extend to 50 digits.
  • Swap RoundingMode.HALF_UP for HALF_EVEN, FLOOR, CEILING — see Rounding Modes.
  • Trigger the safety net: Big('1').divide('3') throws on a non-terminating result.
  • Compare scales: Big('2.0').equals(Big('2.00')) vs Big('2.0').sameValue(Big('2.00')).

Full API

Every method is in the API Reference. Common recipes live in the Cookbook.

Released under the Apache-2.0 License.