Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/rimbu/typical/mod.ts>Num.DivMod

Rimbu is a TypeScript library focused on immutable, performant, and type-safe collections and other tools.
Go to Latest
type alias Num.DivMod
import { type Num } from "https://deno.land/x/rimbu@1.0.2/typical/mod.ts";
const { DivMod } = Num;

Returns a tuple containing the quotient and remainer of dividing the first number by the second.

Examples

Example 1

DivMod<9, 5> => [1, 4]
DivMod<9, 3> => [3, 0]

Type Parameters

N1 extends number
N2 extends number
definition: N2 extends 0 ? never : N1 extends 0 ? [0, 0] : N1 extends N2 ? [1, 0] : StrNum.Divide<StrNum.FromNumber<N1>, StrNum.FromNumber<N2>> extends [infer Q, infer R] ? [StrNum.ToNumber<string & Q>, StrNum.ToNumber<string & R>] : never