abs

Returns the absolute value of the receiver as a new Arith instance.

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

const x = Arith.from("-0.8");
const y = x.abs();
y.toString(); // "0.8"
y.abs().toString(); // "0.8"

Arith.from("-Infinity").abs().toString(); // "Infinity"
Arith.from("NaN").abs().toString(); // "NaN"

// Use the static helper when no method chain is needed.
Arith.abs("-12.5").toString(); // "12.5"

API Reference

Signature

abs(): ArithInstance;

Parameters

ParameterTypeRequiredNotes
None--This method does not take parameters.

Returns

Returns a new Arith instance. The receiver is not modified.

Throws

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

Agent Contract

FieldValue
Kindinstance method and static helper
Canonical nameabs
AliasesNone
Mutates receiverNo
ReturnsArithInstance
Accepts (string, base) overloadNo
Configuration dependenciesNone
Related methodsneg

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.