mirror of https://github.com/koreader/koreader
add math.lua, move all math related helpers in to it
parent
79b3ee91c7
commit
f3452234ea
@ -0,0 +1,25 @@
|
||||
--[[
|
||||
Simple math helper function
|
||||
]]--
|
||||
|
||||
function math.roundAwayFromZero(num)
|
||||
if num > 0 then
|
||||
return math.ceil(num)
|
||||
else
|
||||
return math.floor(num)
|
||||
end
|
||||
end
|
||||
|
||||
function math.round(num)
|
||||
return math.floor(num + 0.5)
|
||||
end
|
||||
|
||||
function math.oddEven(number)
|
||||
if number % 2 == 1 then
|
||||
return "odd"
|
||||
else
|
||||
return "even"
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue