idiv

Alias for dividedToIntegerBy.

Summary

Divides by the supplied value and returns the integer part of the quotient.

AI Contract

FieldValue
Kindinstance method
Canonical namedividedToIntegerBy
AliasesdividedToIntegerBy
Mutates receiverNo
ReturnsArithInstance
Accepts (string, base) overloadYes
Configuration dependenciesNone
Related methodsdividedToIntegerBy

Signature

idiv(n: ArithValue): ArithInstance;
idiv(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.
  • The quotient is rounded toward zero, matching truncating integer division.

Examples

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

new Arith("7").idiv("2").toString(); // "3"

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