H. G. Muller wrote on Thu, Jan 7, 2021 10:32 AM UTC:
I there a notation for octal, hexadecimal or binary constants in GAME code? My current automation code tabulates the capability of a move as bit flags packed into a single word. And often has to test one of these flags. Currently I use the expression & << 1 N #mode for this, where N is a constant indicating the number of the bit I want to test. This slows down the program by requiring extra shift operations at run time. I could of course calsulate how much << 1 N is as a decimal number in every case, and write that into the code instead, but this makes the code very hard to understand, susceptible to typos (N can get quite large, like 28) and therefore hard to debug and maintain. Written as a hexadecimal it would be much more obvious and less error prone, as even for N=28 it would just read 10000000. An alternative would be to have a bit operator such that bit N #mode would calculate & << 1 N #mode (i.e. mask out the Nth bit).
I there a notation for octal, hexadecimal or binary constants in GAME code? My current automation code tabulates the capability of a move as bit flags packed into a single word. And often has to test one of these flags. Currently I use the expression & << 1 N #mode for this, where N is a constant indicating the number of the bit I want to test. This slows down the program by requiring extra shift operations at run time. I could of course calsulate how much << 1 N is as a decimal number in every case, and write that into the code instead, but this makes the code very hard to understand, susceptible to typos (N can get quite large, like 28) and therefore hard to debug and maintain. Written as a hexadecimal it would be much more obvious and less error prone, as even for N=28 it would just read 10000000. An alternative would be to have a bit operator such that bit N #mode would calculate & << 1 N #mode (i.e. mask out the Nth bit).