1. Basics of Shift Operations
--with the same as 1, then 1--or one of 1, 1--not true is false, the rest is true--XOR or the same is 0, the difference is 1--zzmathbit = {} function zzmathbit.__andb
It (left,right)--with return (left = 1 and right = = 1) and 1 or 0 End Function zzmathbit.__orbit (left, right)--or return (left = = 1 or right = = 1) and 1 or 0 End Function zzmathbit.__xorbit (left, right)--XOR return (left + R)
ight) = = 1 and 1 or 0 End Function zzmathbit.__base (left, right, op)--Perform an OP operation on each one and return the value if left < Left, right = right, left end local res = 0 local shift = 1 while left ~= 0 does local RA = Left
% 2--get each bit (rightmost) local RB = right% 2 res = shift * OP (RA,RB) + res shift = Shift * 2 left = MATH.MODF (LEFT/2)--Move right = MATH.MODF (RIGHT/2) End return res End Function Zzmathbit.
Andop (left, right) return Zzmathbit.__base (left, right, zzmathbit.__andbit) End Function Zzmathbit.xorop (left, right) Return zzmathbit.__Base (left, right, zzmathbit.__xorbit) End Function Zzmathbit.orop (left, right) return Zzmathbit.__base (left, right, Z Zmathbit.__orbit) End Function Zzmathbit.notop (left) return to left > 0 and-(left + 1) or-left-1 End Function ZZ Mathbit.lshiftop (left, num)--left move the NUM bit to the right * (2 ^ num) End Function zzmathbit.rshiftop (left,num)--right Move num bit return Math.floor (left/(2 ^ num)) End Function Zzmathbit.test () print (Zzmathbit.andop (65,0x3f))--65 10 00001 111111 print (+) print (Zzmathbit.orop (5678,6789)) print (Zzmathbit.xorop (13579,2468)) PR Int (Zzmathbit.rshiftop (16,3)) print (Zzmathbit.notop ( -4)) print (String.byte ("abc", 1)) End Cclog ("AAAAAAA:") Zzma Thbit.test ()
[Lua-print] Aaaaaaa:
[Lua-print] 1
[Lua-print] 1
[Lua-print] 7855
[Lua-print] 15535
[Lua-print] 2
[Lua-print] 3
[Lua-print] 97
2. Red dot
function Globalservice:hasredpointemail ()
return Zzmathbit.andop (Serverdata.redpointstatus, Dyt. Redpointstatus.email) ~= 0
End
--Red dot State dyt. Redpointstatus = {email = zzmathbit.lshiftop (1, 0),--Mail dailytask = zzmathbit.lshiftop (1, 1),--Daily task C Ommontask = Zzmathbit.lshiftop (1, 2),--Task Draw = Zzmathbit.lshiftop (1, 3),--draw Card sign = Zzmathbit.lshiftop (1, 4),--Sign activity = zzmathbit.lshiftop (1, 5),--7 day Activity Legion = Zzmathbit.lshiftop (1, 6),--Legion Escort = ZZ Mathbit.lshiftop (1, 7),--Escort Collect = zzmathbit.lshiftop (1, 9),--Delegated Union = Zzmathbit.lshiftop (1, 10),-- Linkage Singlerecharge = zzmathbit.lshiftop (1, 11),--limited time activity single recharge Totalrecharge = Zzmathbit.lshiftop (1, 12),--timed activity tired Account Recharge TotalCost = zzmathbit.lshiftop (1, 13),--time-limited activity cumulative consumption oilcost = Zzmathbit.lshiftop (1, 14),--time-limited activity fuel consumption to Taldraw = Zzmathbit.lshiftop (1, 15),--time-limited activity Gold Card qming = zzmathbit.lshiftop (1, 16),--time-limited activities Ching ming good gift Baoxiang = ZZM Athbit.lshiftop (1, 19),--time-limited activity gold extraction Cabo Box Levelfast = zzmathbit.lshiftop (1, 20),--fast replenishment activity levelfastred = Zzmathbi T.lshiftop (1, 21),--fast replenishment Activity red dot}
Therefore, move left first and then represent a unique state. Red dot state: Using the same as Operation 1, then 1, with a 32-bit integer to represent the activity.