mirror of
https://github.com/nmap/nmap.git
synced 2025-12-10 09:49:05 +00:00
Move arshift from bit.lua to bits.lua
This commit is contained in:
@@ -39,6 +39,21 @@ function reverse (n, size)
|
||||
return n
|
||||
end
|
||||
|
||||
--- Returns <code>a</code> arithmetically right-shifted by <code>b</code>
|
||||
-- places.
|
||||
-- @param a Number to perform the shift on.
|
||||
-- @param b Number of shifts.
|
||||
function arshift(a, b)
|
||||
if a < 0 then
|
||||
if a % 2 == 0 then -- even?
|
||||
return a // (1<<b)
|
||||
else
|
||||
return a // (1<<b) + 1
|
||||
end
|
||||
else
|
||||
return a >> b
|
||||
end
|
||||
end
|
||||
do
|
||||
local function test8 (a, b)
|
||||
local r = reverse(a, 8)
|
||||
|
||||
Reference in New Issue
Block a user