I[s] there a notation for octal, hexadecimal or binary constants in GAME code?
No. My tests show that PHP has this feature, but for some reason, it hasn't carried over to GAME Code. It looks like it has to do with handling numbers as strings. In a further test I ran, PHP would convert base 10 strings into numbers, but it would not convert other bases into numbers when they were enclosed by quotation marks. Additionally, PHP's is_numeric() function does not recognize strings in other bases as numeric.
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.
While I could build in conversion to handle this, it might be more costly than using a bit shift.
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.
What I do is use constants with meaningful names. Doing this makes the code much more readable, and it reduces the chance for error by limiting the actual numeric values to some constant assignments.
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).
No. My tests show that PHP has this feature, but for some reason, it hasn't carried over to GAME Code. It looks like it has to do with handling numbers as strings. In a further test I ran, PHP would convert base 10 strings into numbers, but it would not convert other bases into numbers when they were enclosed by quotation marks. Additionally, PHP's is_numeric() function does not recognize strings in other bases as numeric.
While I could build in conversion to handle this, it might be more costly than using a bit shift.
What I do is use constants with meaningful names. Doing this makes the code much more readable, and it reduces the chance for error by limiting the actual numeric values to some constant assignments.
What is #mode supposed to be?