toPrecision
Returns a string rounded to significant digits.
Human Summary
Use it when precision should be described by significant digits rather than fixed decimal places.
AI Contract
Signature
Parameters
Returns
Returns a string.
Behavior
- When
significantDigitsis omitted, returns the unrounded string form. - May use exponential notation when fixed-point notation cannot represent the requested precision cleanly.
- Uses current
ROUNDING_MODEwhenroundingModeis omitted.
Examples
Errors
- Throws if
significantDigitsorroundingModeis invalid.
Agent Notes
- 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.