简体   繁体   English

如何检查给定地址是 32 位还是 64 位?

[英]How can I check if a given address is 32-bit or 64-bit?

How can I check if the address value in a long variable is 32bit or 64bit如何检查 long 变量中的地址值是 32 位还是 64 位

Example:例子:

long a = 0x06000000
long b = 0x13FFF0000

How can I programmatically check the bitness of these addresses?如何以编程方式检查这些地址的位数?

You can use an AND operation to check if any of the higher 32 bits are set.您可以使用 AND 运算来检查是否设置了任何高 32 位。 Assuming that you have ulong because addresses are not negative:假设你有ulong因为地址不是负数:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM