le

Returns whether the receiver is less than or equal to another decimal value.

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

0.3 - 0.2 <= 0.1; // true

const x = Arith.from("0.3").sub("0.2");
x.le("0.1"); // true
Arith.from("1").le(x); // false
Arith.from("2").le("3"); // true

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

API Reference

Signature

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

Parameters

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

Returns

Returns true when the receiver is less than or equal to the comparison value; 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 namele
AliasesNone
Mutates receiverNo
Returnsboolean
Accepts (string, base) overloadYes
Configuration dependenciesSTRICT
Related methodslt, gt, ge, cmp

Agent Notes

  • Use le instead of JavaScript <= on Arith values.
  • Use lt for strict less-than checks.
  • Use string inputs for exact decimal values, especially money-like values.