toString

Returns a string representation of the value.

Human Summary

Use it for compact exact string output. Use toFixed when fixed decimal places are required.

AI Contract

FieldValue
Kindinstance method
Canonical nametoString
AliasesNone
Mutates receiverNo
Returnsstring
Accepts (string, base) overloadNo
Configuration dependenciesEXPONENTIAL_AT, DECIMAL_PLACES, ROUNDING_MODE, ALPHABET
Related methodstoFixed, toFormat, config

Signature

toString(base?: number): string;

Parameters

ParameterTypeRequiredNotes
basenumberNoInteger base from 2 through ALPHABET.length. Defaults to base 10.

Returns

Returns a string.

Behavior

  • Without base, uses base 10 and follows EXPONENTIAL_AT for exponential notation.
  • With base, converts using ALPHABET and rounds according to DECIMAL_PLACES and ROUNDING_MODE.
  • Non-finite values return NaN, Infinity, or -Infinity.

Examples

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

new Arith("255").toString(); // "255"
new Arith("255").toString(16); // "ff"

Errors

  • Throws if base is invalid.

Agent Notes

  • 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