mirror of
https://github.com/Reuh/anselme.git
synced 2025-10-27 16:49:31 +00:00
Add rounding functions
This commit is contained in:
parent
e017a391ec
commit
ccaa40a99d
3 changed files with 44 additions and 61 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue