-
Byte Variable modifiers
Hello,
After looking up modifiers for variables in the manual I saw that there is no way to simply retrieve the lowest 4 bits of a byte, and the highest 4 bits of a byte.
Is this actually available?
If now, what is the easiest way to get the lowest and highest 4 bits of a byte variable?
Thanks
-
And them with %11110000 for the 4 higher bits or and them with %00001111 for the for lower bits.
For the 4 higher bits you could shift them 4 times right to get them on the lower positions
-
Use the bitwise operator "&" like this:
Code:
mynibble = mybyte & %00001111 'Put the lower 4 bits into mynibble
myothernibble = mybyte & %11110000 'Put the upper 4 bytes into myothernibbe
steve
Dohh! Mat beat me to it. :)
-
You could do this:
Code:
highbits = yourbyte / 16
lowbits = yourbyte // 16