Help Converting Java Bitwise Operations to Xojo

I’m converting an old java program to Xojo, and have run across a few lines of bit operations that I need to make sure are exactly correct in the resulting Xojo code.

Here’s one: ((prevNibble ^ currentIndex++) << 4 | highNibble) + 593
And another: i &=15

As I understand things, in english the first one is doing an exclusive OR with prevNibble and currentIndex++, then shifting that result 4 to the left, then ORing that result with whatever is in highNibble, and finally adding 593 to the whole thing.

The second one is just doing an “And equals” operation - i AND EQUALS 15.

So, anyone feel like taking a stab at how to do this in Xojo?

Thanks!

Based on your text description:

currentIndex = currentIndex + 1
v = ( BitWise.ShiftLeft( prevNibble XOr currentIndex, 4 ) Or highNibble ) + 593
i = i And 15

Thanks, Kem. Trying it now! :slight_smile:

postfix ++ means increment after the operation, thus

v = ( BitWise.ShiftLeft( prevNibble XOr currentIndex, 4 ) Or highNibble ) + 593
currentIndex = currentIndex + 1

Good catch, Tim.