1. ホーム
  2. スクリプト・コラム
  3. ルア

Lua math.fmodの小数点以下の桁数問題

2022-02-10 17:07:27
Lua math.fmod uses the following decimals.
--Returns the remainder of the division of x by y.
function math.fmod (x, y) end //Take the modulo operation

Here you need to pay attention to decimals, see the following two examples.
1.
local x = math.fmod(15, 4)
print(x)

Result: 4

2.
local x = math.fmod(15.3, 4)
print(x)

Result: 3.3

3.
local x = math.fmod(15, 4.1)
print(x)

Result: 2.7