sd
Getter/setter-style method for significant digits.
Human Summary
Call with no numeric argument to inspect significant digits, or with a number to round by significant digits.
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 numeric
significantDigits, returns the number of significant digits ornullfor non-finite values. - When
includeZerosistrue, integer-part trailing zeros are counted. - With numeric
significantDigits, returns a rounded copy.
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.