math.fmod()

Type Function
Library math.*
Return value Number
Revision Release 2024.3703
Keywords fmod

Overview

Returns the remainder of the division of x by y that rounds the quotient towards zero.

The remainder of a division operation is the result of subtracting the integral quotient multiplied by the denominator from the numerator:

remainder = numerator - quotient * denominator

Syntax

math.fmod( x, y )
x (required)

Number. The numerator of the quotient.

y (required)

Number. The denominator of the quotient.

Examples

print(math.fmod(5.3, 2))     ---> 1.3
print(math.fmod(1, 0))    ---> NaN