toNumber

Returns the JavaScript number representation.

Human Summary

Use only at boundaries where binary floating-point precision loss is acceptable.

AI Contract

FieldValue
Kindinstance method
Canonical nametoNumber
AliasesNone
Mutates receiverNo
Returnsnumber
Accepts (string, base) overloadNo
Configuration dependenciesNone
Related methodstoString, toBigInt

Signature

toNumber(): number;

Parameters

ParameterTypeRequiredNotes
None--This method does not take parameters.

Returns

Returns a JavaScript number.

Behavior

  • May lose precision for large or high-precision decimal values.
  • Preserves JavaScript non-finite values as NaN or infinities.
  • Does not mutate the receiver.

Examples

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

new Arith("1.25").toNumber(); // 1.25

Errors

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

Agent Notes

  • Avoid toNumber() in generated code unless the caller explicitly accepts precision loss.
  • 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