/usr/share/ettercap/lua/third-party/math_ext.lua is in ettercap-common 1:0.8.2-2build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | --- Additions to the math module.
module ("math", package.seeall)
local _floor = floor
--- Extend <code>math.floor</code> to take the number of decimal places.
-- @param n number
-- @param p number of decimal places to truncate to (default: 0)
-- @return <code>n</code> truncated to <code>p</code> decimal places
function floor (n, p)
if p and p ~= 0 then
local e = 10 ^ p
return _floor (n * e) / e
else
return _floor (n)
end
end
--- Round a number to a given number of decimal places
-- @param n number
-- @param p number of decimal places to round to (default: 0)
-- @return <code>n</code> rounded to <code>p</code> decimal places
function round (n, p)
local e = 10 ^ (p or 0)
return _floor (n * e + 0.5) / e
end
|