util.math.fmod
Shared
Returns the remainder of a division between two numbers
Syntax
local result = util.math.fmod(
dividend,
divisor
)Parameters
| Type | Name | Description |
|---|---|---|
float | dividend | Number to divide |
float | divisor | Number to divide by |
Returns
| Type | Name | Description |
|---|---|---|
float | result | Remainder of dividend/divisor with the same sign as dividend |
Examples
local result = util.math.fmod(10, 3)
core.engine.print("info", result) -- 1.0local result = util.math.fmod(5.5, 2.0)
core.engine.print("info", result) -- 1.5local result = util.math.fmod(-10, 3)
core.engine.print("info", result) -- -1.0local result = util.math.fmod(7, 7)
core.engine.print("info", result) -- 0.0local angle = 450.0
local wrapped = util.math.fmod(angle, 360)
core.engine.print("info", wrapped) -- 90.0local elapsed = 7.3
local period = 2.0
local phase = util.math.fmod(elapsed, period)
core.engine.print("info", phase) -- 1.3local a, b = 7.5, 2.5
core.engine.print("info", util.math.fmod(a, b)) -- 0.0