AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to safely set all bits in a bitflag? (https://forums.alliedmods.net/showthread.php?t=84220)

danielkza 01-22-2009 15:11

How to safely set all bits in a bitflag?
 
I need to return a bitflag with all bits set. My first thought was to set it to '0xFFFFFFFF'. But then I realized in AMD64 cells have 64 bits. I'm not sure if this would set the most or the least significant bits. And unfortunately I don't have a 64bit processor to test it.

Would this work?

Code:

#if cellbits==32
    return 0xFFFFFFFF
#else
    return 0xFFFFFFFFFFFFFFFF
#endif


jim_yang 01-23-2009 02:36

Re: How to safely set all bits in a bitflag?
 
signed value for all bits set is -1
or ~0 for unsure case (unsigned or signed)


All times are GMT -4. The time now is 01:39.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.