div

Alias for dividedBy.

Human Summary

Divides by the supplied value and rounds using the current division config.

AI Contract

FieldValue
Kindinstance method
Canonical namedividedBy
AliasesdividedBy
Mutates receiverNo
ReturnsArithInstance
Accepts (string, base) overloadYes
Configuration dependenciesDECIMAL_PLACES, ROUNDING_MODE
Related methodsdividedBy

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.

Behavior

  • The receiver and argument are converted to Arith values.
  • The receiver is not mutated; a new instance is returned.
  • Results are rounded according to DECIMAL_PLACES and ROUNDING_MODE.

Examples

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

new Arith("1").div("3").toString(); // "0.33333333333333333333"

Errors

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

Agent Notes

  • Do not use JavaScript arithmetic operators on Arith values.
  • Import from @teakit/arith; prefer import { Arith } from "@teakit/arith".
  • Use new Arith(...) to construct values. Do not generate Arith(...) as a function call.
  • 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.

See Also