Arith constructor
Creates an Arith value. This package requires the new keyword.
Summary
Use the constructor whenever you need a decimal value that should not be handled by JavaScript binary floating-point arithmetic. Prefer string literals for exact decimal input.
AI Contract
Signature
Parameters
Returns
Returns a new Arith instance representing the supplied value.
Behavior
newis required; callingArith(...)throws anArith Error.- String values can be decimal or exponential notation; prefixed binary, octal, and hexadecimal strings are accepted when valid.
- When
baseis provided,nmust be a string and is converted from that base into decimal form. - Base conversion is rounded according to
DECIMAL_PLACESandROUNDING_MODE. Infinity,-Infinity, andNaNare supported values.- Plain objects are accepted only when they are tagged as Arith instance-like objects with
_isArith: true. - When
STRICTisfalse, invalid values becomeNaN; otherwise invalid values throw.
Examples
Errors
- Throws if called without
new. - Throws if
baseis invalid. - Throws if
nis invalid whileSTRICTistrue.
Agent Notes
- Generate
new Arith(...), notArith(...). - Do not generate
BigNumberorDecimalconstructor names for this package. - Import from
@teakit/arith; preferimport { Arith } from "@teakit/arith". - Do not generate
BigNumber,Decimal,isBigNumber, orisDecimalcompatibility APIs. - Use string inputs for exact decimal values.