toObject

Returns the receiver's coefficient, exponent, and sign as a plain object.

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

const x = Arith.from("777.123");
const object = x.toObject();

object.c; // [777, 12300000000000]
object.e; // 2
object.s; // 1

// Add the Arith marker to recreate the value without reparsing a string.
const y = Arith.from({ ...object, _isArith: true });
x.eq(y); // true

// The returned coefficient is copied, so editing it does not mutate the source value.
object.c?.push(999);
x.toString(); // "777.123"

API Reference

Signature

toObject(): ArithObject;

Parameters

ParameterTypeRequiredNotes
None--This method does not take parameters.

Returns

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

Throws

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

Agent Contract

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

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 with import { Arith } from "@teakit/arith"; default imports are unsupported.
  • Use Arith.from(...) to create values. Do not generate new Arith(...) or Arith(...).
  • 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.