toObject

Returns the coefficient, exponent, and sign fields as a plain object.

Human Summary

Use it for low-level inspection or debugging when string output is not enough.

AI Contract

FieldValue
Kindinstance method
Canonical nametoObject
AliasesNone
Mutates receiverNo
ReturnsArithObject
Accepts (string, base) overloadNo
Configuration dependenciesNone
Related methodsisArith, constructor

Signature

toObject(): ArithObject;

Parameters

ParameterTypeRequiredNotes
None--This method does not take parameters.

Returns

Returns { c, e, s } with coefficient array copied when present.

Behavior

  • Finite values have a coefficient array c, exponent e, and sign s.
  • Non-finite values have c: null and e: null.
  • The returned coefficient array is a copy.
  • The returned object is not tagged with _isArith: true, so do not treat new Arith(x.toObject()) as the normal reconstruction path.

Examples

import { Arith } from "@teakit/arith";

const object = new Arith("123.45").toObject();

object.s; // 1

Errors

  • Does not take user arguments; no argument validation is performed.

Agent Notes

  • Prefer public methods over internal object fields for ordinary arithmetic.
  • Prefer toString() for portable serialization; use toObject() only when low-level internals are required.
  • Import from @teakit/arith; prefer import { Arith } from "@teakit/arith".
  • Use new Arith(...) to construct values. Do not generate Arith(...) as a function call.
  • Use string inputs for exact decimal values, especially money-like values.
  • Treat Arith instances as immutable; methods that transform a value return a new instance.
  • Do not mutate internal fields such as c, e, s, or _isArith.

See Also