mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-13 01:10:19 -04:00
fix bit32.lrotate and bit32.rrotate
If any of two arguments were too big, those functions returned 0 instead of an expected value. E.g., bit32.lrotate(11111111111111111,2222222222222) --> 0 Expected return value: 3340540761.
This commit is contained in:
parent
2a5de6868a
commit
b95cf7cae9
@ -66,9 +66,15 @@ function bit32.replace(n, v, field, width)
|
||||
end
|
||||
|
||||
function bit32.lrotate(x, disp)
|
||||
if disp == 0 then return x
|
||||
elseif disp < 0 then return bit32.rrotate(x, -disp)
|
||||
else return trim((x << disp) | (x >> (32 - disp))) end
|
||||
if disp == 0 then
|
||||
return x
|
||||
elseif disp < 0 then
|
||||
return bit32.rrotate(x, -disp)
|
||||
else
|
||||
disp = disp & 31
|
||||
x = trim(x)
|
||||
return trim((x << disp) | (x >> (32 - disp)))
|
||||
end
|
||||
end
|
||||
|
||||
function bit32.lshift(x, disp)
|
||||
@ -76,9 +82,15 @@ function bit32.lshift(x, disp)
|
||||
end
|
||||
|
||||
function bit32.rrotate(x, disp)
|
||||
if disp == 0 then return x
|
||||
elseif disp < 0 then return bit32.lrotate(x, -disp)
|
||||
else return trim((x >> disp) | (x << (32 - disp))) end
|
||||
if disp == 0 then
|
||||
return x
|
||||
elseif disp < 0 then
|
||||
return bit32.lrotate(x, -disp)
|
||||
else
|
||||
disp = disp & 31
|
||||
x = trim(x)
|
||||
return trim((x >> disp) | (x << (32 - disp)))
|
||||
end
|
||||
end
|
||||
|
||||
function bit32.rshift(x, disp)
|
||||
|
Loading…
x
Reference in New Issue
Block a user