# Bitwise operations in XOJO-ios

**URL:** <https://forum.xojo.com/t/bitwise-operations-in-xojo-ios/51816>\
**Category:** iOS\
**Created:** [December 30, 2019, 3:30pm UTC](https://forum.xojo.com/t/bitwise-operations-in-xojo-ios/51816 "2019-12-30T15:30:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dick\_Bierman](https://forum.xojo.com/letter_avatar_proxy/v4/letter/d/8491ac/32.png) [@Dick\_Bierman](https://forum.xojo.com/u/Dick_Bierman)\
**Post date:** [December 30, 2019, 3:30pm UTC](https://forum.xojo.com/t/bitwise-operations-in-xojo-ios/51816/1 "2019-12-30T15:30:38Z")

</div>

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  
else  
score = score - 1  
end if  
mask = Bitwise.shiftleft(mask,1)  
next i

---

<div class="post-metadata">

**Author:** ![Jason\_King](https://forum.xojo.com/letter_avatar_proxy/v4/letter/j/e480ec/32.png) [@Jason\_King](https://forum.xojo.com/u/Jason_King)\
**Post date:** [December 30, 2019, 4:27pm UTC](https://forum.xojo.com/t/bitwise-operations-in-xojo-ios/51816/2 "2019-12-30T16:27:23Z")

</div>

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`

---

<div class="post-metadata">

**Author:** ![Kem\_Tekinay](https://forum.xojo.com/user_avatar/forum.xojo.com/kem_tekinay/32/154_2.png) [@Kem\_Tekinay](https://forum.xojo.com/u/Kem_Tekinay)\
**Post date:** [December 30, 2019, 4:30pm UTC](https://forum.xojo.com/t/bitwise-operations-in-xojo-ios/51816/3 "2019-12-30T16:30:51Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Kem\_Tekinay](https://forum.xojo.com/user_avatar/forum.xojo.com/kem_tekinay/32/154_2.png) [@Kem\_Tekinay](https://forum.xojo.com/u/Kem_Tekinay)\
**Post date:** [December 30, 2019, 4:40pm UTC](https://forum.xojo.com/t/bitwise-operations-in-xojo-ios/51816/4 "2019-12-30T16:40:06Z")

</div>

Also, cast your mask, number, “2”, and the shift positions as UInteger rather than Integer.

---

<div class="post-metadata">

**Author:** ![Dick\_Bierman](https://forum.xojo.com/letter_avatar_proxy/v4/letter/d/8491ac/32.png) [@Dick\_Bierman](https://forum.xojo.com/u/Dick_Bierman)\
**Post date:** [January 2, 2020, 2:42pm UTC](https://forum.xojo.com/t/bitwise-operations-in-xojo-ios/51816/5 "2020-01-02T14:42:35Z")

</div>

Thanks to all

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [April 29, 2021, 4:14pm UTC](https://forum.xojo.com/t/bitwise-operations-in-xojo-ios/51816/6 "2021-04-29T16:14:05Z")

</div>


