Skip to content

modulo

The modulo() method returns the remainder of the Euclidean division of two numbers. This operation is useful to determine parity, create circular rotations, or handle pagination.

Interactive example

Syntax

Classic signature

typescript
function modulo<
	GenericInput extends number
>(
	input: GenericInput,
	divisor: number
): number

Curried signature

typescript
function modulo<
	GenericInput extends number
>(
	divisor: number
): (input: GenericInput) => number

Parameters

  • input: The dividend (the number to divide, classic signature only).
  • divisor: The divisor (the number to divide by).

Return value

returns the remainder of the Euclidean division of input by divisor. The result has the same sign as the dividend (input % divisor).

See also

  • divide - Divides two numbers
  • floor - Rounds a number down

Sources

Released under the MIT license.