toNearest
Rounds the receiver to the nearest multiple of a supplied step value.
API Reference
Signature
Parameters
Returns
Returns a new Arith instance rounded to a multiple of step.
Throws
- Throws if
stepis zero, negative,NaN, or infinite. - Throws if
roundingModeis invalid. - Throws if an input value is invalid while
STRICTistrue.
Agent Contract
Agent Notes
- Use string inputs for exact step sizes.
- Use
decimalPlaces(decimalPlaces, roundingMode?)when the rule is decimal places; usetoNearest()for ticks, lot sizes, or other step multiples. - Treat
Arithinstances as immutable.