Home > Back-end >  How can I check if a given address is 32-bit or 64-bit?
How can I check if a given address is 32-bit or 64-bit?

Time:10-24

How can I check if the address value in a long variable is 32bit or 64bit

Example:

long a = 0x06000000
long b = 0x13FFF0000

How can I programmatically check the bitness of these addresses?

CodePudding user response:

You can use an AND operation to check if any of the higher 32 bits are set. Assuming that you have ulong because addresses are not negative:

if ((x & 0xFFFFFFFF00000000UL) == 0)
    Console.WriteLine("x would fit into 32 bit");
  • Related