Flag comparison

I am attempting to “resolve” a flag comparison mechanism I am putting in place when comparing Ints with others as if they were flags.

@:noCompletion private function flagComparison(original:Int, current:Int)
        return cast (original - current < 0 && (original - current) % 2 == 0);

With the following code, the idea is to check if the current “flag” is contained in the total “flags” original. To do so, I firstly minus current by the original, and also check to see if the subtraction can be divided by two with no remainders, essentially saying that 1 is not included in the flags 2 + 4 (6 in total). Of course, this does mean that 1 cannot be used as a flag, which defeats the point of the comparison if you do use 1 at any point.

Is there a more optimal way of checking this or just don’t use the number 1?

And now that I think about it that’s not optimal at all…

In an example such as 2 + 8 (10), 4 can technically be evaluated as true, which is not a result you would want…

Well, in any case:

current & original != 0;

works fine.