The following code results in ’ This item doesn’t exist’ for all lines wit a Bitwise operation. This is intended for an ios-device.
dim score, mask, i, bit As integer
for i= 0 to 15
bit = Bitwise.BitAnd(number, mask)
if bit >0 then
score = score +1
score = score - 1
mask = Bitwise.shiftleft(mask,1)
You can just use the
and/or/xor/not operators without the bitwise module. As for shifting, left shift of
x << y is the same as
x * 2^y and right shift of
x >> y is the same as
x / 2^y
For shift right, I’d use the “” for integer division.
Incidentally, you can do this for desktop or web apps too, and it will be faster.
Also, cast your mask, number, “2”, and the shift positions as UInteger rather than Integer.