toString

Returns a compact string representation of the receiver.

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

const x = Arith.from("255.5");

x.toString(); // "255.5"
x.toString(16); // "ff.8"
x.toString(2); // "11111111.1"

const y = Arith.from("1.23456789");
y.toString(); // "1.23456789"

// Passing base 10 applies current base-conversion precision settings.
const Short = Arith.clone({ DECIMAL_PLACES: 4 });
Short.from("1.23456789").toString(10); // "1.2346"

Arith.from("1e+21").toString(); // "1e+21"

API Reference

Signature

toString(base?: number): string;

Parameters

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

Returns

Returns a string.

Throws

  • Throws if base is invalid.

Agent 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

Agent Notes

  • 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.