eq

Returns whether the receiver is exactly equal to another decimal value.

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

0 === 1e-324; // true

const x = Arith.from("0");
x.eq("1e-324"); // false
Arith.from("-0").eq(x); // true
Arith.from("0.1").add("0.2").eq("0.3"); // true

// Use the (string, base) overload when the comparison value is written in another base.
Arith.from("10").eq("a", 16); // true

// Like JavaScript, NaN does not equal NaN.
Arith.from("NaN").eq("NaN"); // false

API Reference

Signature

eq(n: ArithValue): boolean;
eq(n: string, base: number): boolean;

Parameters

ParameterTypeRequiredNotes
nArithValueYesValue to convert to Arith before applying the operation.
basenumberNoOnly valid with the (string, base) overload. Must be an integer from 2 through ALPHABET.length.

Returns

Returns true when values compare equal; otherwise returns false.

Throws

  • Throws if base is invalid.
  • Throws if the comparison value is invalid while STRICT is true.

Agent Contract

FieldValue
Kindinstance method
Canonical nameeq
AliasesNone
Mutates receiverNo
Returnsboolean
Accepts (string, base) overloadYes
Configuration dependenciesSTRICT
Related methodsne, cmp

Agent Notes

  • Use comparison methods instead of JavaScript comparison operators on Arith values.
  • 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.