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

When NOT to use

Non-finite or special float values

NaN, Infinity, -Infinity are deliberately unsupported — construction throws DecimalError (NON_FINITE). If your domain needs them (statistics, sensor streams, scientific computing), use number or a domain-specific type.

Transcendental / irrational math

There is no sqrt, log, sin, exp — a Decimal is always a finite rational base-10 number. Irrational results would require an infinite expansion. Use number (or Math.*) for geometry, statistics, physics.

Hot-loop performance on integers

bigint arithmetic is fast but still allocates per operation. For pure integer counters, indexes, pagination, bitmasks — number (or bigint directly) is cheaper. Decimal pays for exactness you may not need.

Ratios that must stay rational forever

div truncates at a finite scale (PG-faithful default or explicit). If you need to keep 1/3 as a symbolic rational for later exact arithmetic, you need a rational-number library (numerator/denominator pairs) — isPeriodic only tells you a truncation happened.

Rule of thumb

  • Values that must match numeric columns or money semantics → Decimal
  • Counts, indexes, flags → number/bigint
  • Scientific/statistical math → number + domain library
Last modified on October 28, 2026
When to useExamples
On this page
  • Non-finite or special float values
  • Transcendental / irrational math
  • Hot-loop performance on integers
  • Ratios that must stay rational forever
  • Rule of thumb