The primary functions You'll find useful in this UDF are _FlagSet and _FlagClear, although you'll notice that you can use _FlagSet to clear a flag - I did this so that you can pass the results of a true/false expression directly through the flag, and not have to write an IF statement. For example:
$Flags = _FlagSet($Flags, 3, $i > 0)
will set bit 3 high if $i > 0, or low if not.
There is also _FlagSetInPlace and _FlagClearInPlace, that use a ByRef instead of a return. That looks cleaner is some situations.
Also notice the _FlagToString function, which is basically a value-to-binary-string function.
And notice that i used a pre-determined set of flag masks, instead of calculating 2^x each and every time. I have actually done a performance check, but I'm assuming that this is faster.
Enjoy! And as always, comments are welcome!