1
0
Fork 0
mirror of https://github.com/Reuh/anselme.git synced 2025-10-28 00:59:31 +00:00

Add rounding functions

This commit is contained in:
Étienne Fildadut 2022-09-16 22:04:30 +09:00
parent e017a391ec
commit ccaa40a99d
3 changed files with 44 additions and 61 deletions

View file

@ -386,6 +386,16 @@ lua_functions = {
["rand()"] = function() return math.random() end,
["rand(a::number)"] = function(a) return math.random(a) end,
["rand(a::number, b::number)"] = function(a, b) return math.random(a, b) end,
["floor(a::number)"] = function(a) return math.floor(a) end,
["ceil(a::number)"] = function(a) return math.ceil(a) end,
["round(a::number, increment=1::number)"] = function(a, increment)
local n = a / increment
if n >= 0 then
return math.floor(n + 0.5) * increment
else
return math.ceil(n - 0.5) * increment
end
end,
["unannotated(v)"] = {
mode = "raw",
value = function(v)