neg

Returns a new Arith value with the opposite sign.

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

const x = Arith.from("1.8");
x.neg().toString(); // "-1.8"

const y = Arith.from("-1.3");
y.neg().toString(); // "1.3"

// Negative zero changes sign when negated.
Arith.from("-0").neg().valueOf(); // "0"
Arith.from("0").neg().valueOf(); // "-0"

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

API Reference

Signature

neg(): ArithInstance;

Parameters

ParameterTypeRequiredNotes
None--This method does not take parameters.

Returns

Returns a new Arith instance.

Throws

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

Agent Contract

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

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.