Hi
I'm trying to do some simple binary arithamtic, but in addition to the fact that my binary is a little rusty, I can not find out the Blitz Max syntax/commands for doing what I need.
Bascially I have 2 variables that consist of 4 bits each (each bit represents the edge of a tile) and I am doing a logical And to determine whether the tile will "fit" inside the other. This bit is fine, e.g.
This works just fine. However, I also need to do a "bitwise rotate" on these values. By rotate, I mean similar to a bitwise shift, but the bits wrap around, so rotating %1000 left by one would result in %0001, %1100 would be %1001 etc.
I thought I might be able to do it by converting the binary to a string, rotating it, then converting back. There are two problems with this - first, it does not seem a very effcient way of doing it, and second, I can not find a way of converting the binary string back to an integer value.
I'm sure this is simple to do but my brain refuses to cooperate with me ;-) Any help would be greatly appreciated.
I'm trying to do some simple binary arithamtic, but in addition to the fact that my binary is a little rusty, I can not find out the Blitz Max syntax/commands for doing what I need.
Bascially I have 2 variables that consist of 4 bits each (each bit represents the edge of a tile) and I am doing a logical And to determine whether the tile will "fit" inside the other. This bit is fine, e.g.
var1 = %1110 var2 = %0110 If var1 & var2 = var2 then 'do stuff end if
This works just fine. However, I also need to do a "bitwise rotate" on these values. By rotate, I mean similar to a bitwise shift, but the bits wrap around, so rotating %1000 left by one would result in %0001, %1100 would be %1001 etc.
I thought I might be able to do it by converting the binary to a string, rotating it, then converting back. There are two problems with this - first, it does not seem a very effcient way of doing it, and second, I can not find a way of converting the binary string back to an integer value.
I'm sure this is simple to do but my brain refuses to cooperate with me ;-) Any help would be greatly appreciated.