I'm doing something with bitflags, and I want to #define a number as ALL_FLAGS so I can just set the variable on some mobs to ALL_FLAGS so I don't have to go back to all things that should have all flags every time a new flag is added.
However, I have no idea what this number should be.
Experiments point out that 524288 should be the largest number (that is not automatically turned into stuff like 1.20654e+006), but 524289 also works fine and is not turned into scientific notation.
(While it is unlikely that I will ever need 19 flags, this #define would also be used for other things)
Aug 4 2014, 2:42 am
|
|
I wonder if 1.#INF would work.
|
BYOND uses single-precision floating point for its numbers, and only supports bit-wise operations for the first 16 bits (between 0 and 65535), so a value of 65535 would set all of those bits to 1.
|
You can also save yourself the work of figuring out what it needs to be.
#define FLAG_ONE 1 Now setting a bitflag to FLAG_ALL will enable all of the FLAG_ bits you have defined there. |
That would defeat the point though. If I added a new flag I would still have to add it to that #define and I would not be able to use the #define for other bitflags.
|
It doesn't really defeat the purpose, you're still not having to go back to every place you've used FLAG_ALL to change it, just the one place. I get what you wanted though originally and the answer provided will do what you need, I was just elaborating on a method to combine the value of multiple flags without having to worry about the math involved -- mostly for other people reading this interested in using bitflags (and you, in case you didn't know of it but I figured you probably had an idea)
|