Skip to main content

fmod

Function fmod 

Source
pub fn fmod(x: number, y: number) -> number
Expand description

Returns the remainder of a division, rounding the quotient towards zero (integer/float).

§Parameters

  • x: the dividend.
  • y: the divisor.

§Return value

The remainder of x / y with the sign of x. Note that the % operator behaves differently: it rounds the quotient towards minus infinity, so the result takes the sign of the divisor.

§Examples

print(math.fmod(7, 3))     --> 1
print(math.fmod(-7, 3))    --> -1
print(-7 % 3)              --> 2   (the operator rounds differently)