➗ Returns a tuple containing the quotient and the remainder of two numbers.

Syntax

TypeScript
import { divMod } from '@opentf/std';

divMod(x: number, y: number): [quotient: number, remainder: number]

Parameters

  • x: The dividend.

  • y: The divisor.

Returns

A tuple where the first element is the quotient (x / y) and the second is the remainder (x % y).

Examples

TypeScript
divMod(4, 2) //=> [2, 0]

divMod(11, 4) //=> [2.75, 3]

divMod(1, 0) //=> [Infinity, NaN]

divMod(0, 1) //=> [0, 0]

divMod(-9, -2) //=> [4.5, -1]
Last updated on
Edit this page