P
perldude
A third-party module that I'm using has a couple of binary constants defined:
GENERIC_READ=10000000000000000000000000000000
GENERIC_EXECUTE=100000000000000000000000000000
The binary value for GENERIC_READ|GENERIC_EXECUTE would be:
10100000000000000000000000000000
I'm trying to check if a field in an object created by the module equals
GENERIC_READ|GENERIC_EXECUTE, but I'm running into a problem. If I print out
the value for a field that I know equals GENERIC_READ|GENERIC_EXECUTE, then it
prints out -1610612736.
But when I have the statement "print GENERIC_READ|GENERIC_EXECUTE", it prints
out 2684354560.
The following statements both print out 10100000000000000000000000000000:
printf("%0b\n", 2684354560);
printf("%0b\n", -1610612736);
So the binary representation for GENERIC_READ|GENERIC_EXECUTE has 2 different
decimal representations, a positive one and a negative one. Why does the
field in the object created by the third-party module have a negative decimal
representation, while my own code has a positive decimal representation?
GENERIC_READ=10000000000000000000000000000000
GENERIC_EXECUTE=100000000000000000000000000000
The binary value for GENERIC_READ|GENERIC_EXECUTE would be:
10100000000000000000000000000000
I'm trying to check if a field in an object created by the module equals
GENERIC_READ|GENERIC_EXECUTE, but I'm running into a problem. If I print out
the value for a field that I know equals GENERIC_READ|GENERIC_EXECUTE, then it
prints out -1610612736.
But when I have the statement "print GENERIC_READ|GENERIC_EXECUTE", it prints
out 2684354560.
The following statements both print out 10100000000000000000000000000000:
printf("%0b\n", 2684354560);
printf("%0b\n", -1610612736);
So the binary representation for GENERIC_READ|GENERIC_EXECUTE has 2 different
decimal representations, a positive one and a negative one. Why does the
field in the object created by the third-party module have a negative decimal
representation, while my own code has a positive decimal representation?