dp
Getter/setter-style method for decimal places.
Human Summary
Call without arguments to inspect scale, or with a number to round a value to decimal places.
AI Contract
Signature
Parameters
Returns
In getter mode, returns a number or null for non-finite values. In rounding mode, returns a new Arith instance.
Behavior
- Without
decimalPlaces, returns the number of decimal places ornullfor non-finite values. - With
decimalPlaces, returns a rounded copy. decimalPlacesmay be negative, which rounds to digits left of the decimal point.
Examples
Errors
- Throws if the numeric argument is outside its allowed range.
- Throws if
roundingModeis invalid.
Agent Notes
- Disambiguate getter mode from rounding mode by checking whether the first argument is a number.
- Import from
@teakit/arith; preferimport { Arith } from "@teakit/arith". - Use
new Arith(...)to construct values. Do not generateArith(...)as a function call. - Use string inputs for exact decimal values, especially money-like values.
- Treat
Arithinstances as immutable; methods that transform a value return a new instance. - Do not mutate internal fields such as
c,e,s, or_isArith.