PrimeBrickPrimeBrick
  • Docs
  • Contact
  • MIT License
  • Documentation
  • MCP Server
  • API Catalog
  • Services
  • Libraries
PrimeBrickPrimeBrick

© 2026 PrimeBrick. MIT License. v3.11.2

github
DAL Library
SDK Library
Decimal Library
    Developer Guide
      Getting startedPrecision modelDivision and periodicityRoundingWire formatWhen to useWhen NOT to useExamplesAPI ReferenceContributing
powered by Zudoku
Developer Guide

Rounding

RoundingMode accepts the classic BigDecimal mode names:

ModeBehavior
UPAway from zero
DOWNToward zero (truncation)
CEILINGToward +∞
FLOORToward −∞
HALF_UPNearest, ties away from zero — default, matches PG round()
HALF_DOWNNearest, ties toward zero
HALF_EVENNearest, ties to even digit (banker's rounding)

Where modes apply

Code
round("12.345", 2); // 12.35 (HALF_UP default) round("12.345", 2, "HALF_EVEN"); // 12.34 (banker's) rescale("9.876", 1); // 9.9 setScale("9.876", 3, "DOWN"); // 9.876 — pads or truncates to exactly 3 div(a, b, { scale: 6, rounding: "FLOOR" });// floor division at scale 6

Related transforms

  • trunc(d) — integer part (toward zero)
  • floor(d) / ceil(d) — integer toward −∞ / +∞
  • normalize(d) — strip trailing zeros (12.3400 → 12.34; v/scale minimized). Note: normalize changes scale, so strictEq on a normalized and un-normalized equal value is false — use eq for value comparison.
Last modified on October 28, 2026
Division and periodicityWire format
On this page
  • Where modes apply
  • Related transforms
TypeScript