div

Divides the receiver by another value using the current division configuration.

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

1 / 3; // 0.3333333333333333

const x = Arith.from("355");
const y = Arith.from("113");

x.div(y).toString(); // "3.14159292035398230088"
x.div("5").toString(); // "71"

// Use the (string, base) overload when the divisor is written in another base.
x.div("47", 16).toString(); // "5"

// Division follows the constructor's precision config.
const Money = Arith.clone({ DECIMAL_PLACES: 2 });
Money.from("1").div("3").toString(); // "0.33"

// Use the static helper when no method chain is needed.
Arith.div("1", "4").toString(); // "0.25"

API Reference

Signature

div(n: ArithValue): ArithInstance;
div(n: string, base: number): ArithInstance;

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 a new Arith instance. The receiver is not modified.

Throws

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

Agent Contract

FieldValue
Kindinstance method and static helper
Canonical namediv
AliasesNone
Mutates receiverNo
ReturnsArithInstance
Accepts (string, base) overloadYes
Configuration dependenciesDECIMAL_PLACES, ROUNDING_MODE
Related methodsidiv, mod

Agent Notes

  • Do not use JavaScript arithmetic 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.