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.
Things to try
- Change
MC(15, ...)toMC(50, ...)and watch1/3extend to 50 digits. - Swap
RoundingMode.HALF_UPforHALF_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'))vsBig('2.0').sameValue(Big('2.00')).
Full API
Every method is in the API Reference. Common recipes live in the Cookbook.