You know how you can declare variables in oct, and hex?
var/dec = 20
var/oct = 024
var/hex = 0x14
Well, I was just curious, is there a way you can declare them in binary form? This would make it slightly easier for making bitwise type stuff.
ID:273377
Mar 9 2010, 3:03 pm
|
|
In response to Garthor
|
|
I meant like...
#define FLAG bin-1 It just made me curious if you could give the variables a value in dec, oct, hex, and bin. EDIT: Useless, but I just wanted to know more. |
In response to Ranch Jolly
|
|
If you really, really need to, you can use the << bit-shift operator. Though, you'd want to use a constant variable rather than a #define in that case. So, 1 in binary becomes 1 << 0, 10 becomes 1 << 1, 100 becomes 1 << 2, and so on.
|
In response to Garthor
|
|
Garthor wrote:
If you really, really need to, you can use the << bit-shift operator. Though, you'd want to use a constant variable rather than a #define in that case. So, 1 in binary becomes 1 << 0, 10 becomes 1 << 1, 100 becomes 1 << 2, and so on. I didn't think of that, thank you very much. |
For bitwise type stuff, there really shouldn't be a need for this. Each bit should have its own constant and you can just | constants together. Like mob/sight (SEE_SELF|SEE_TURFS) or dir (NORTH|EAST == NORTHEAST).
So, you'd want to do: