大佬教程收集整理的这篇文章主要介绍了位掩码问题?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
该表达式(1 << n)
等效于2的n次幂。
您撰写(1 << n) | (1 << m)
本文时(1 << n) + (1 <<
m)
,只要n
和相同,@H_208_3@m就不同。因此,您可以根据需要以简单的添加方式来考虑它。
数12414
以二进制是11000001111110
所以它是下列标志的总和(或按位OR):
交易1 << 1 = 2
卖1 << 2 = 4
可存储1 << 3 = 8
STORABLE_IN_WH 1 << 4 = 16
STORABLE_IN_LEGION_WH 1 << 5 = 32
易碎1 << 6 = 64
BLACK_CLOUD_TradERS 1 << 12 = 4096
CAN_SPliT 1 << 13 = 8192
=======================================
总计= 12414
请注意,当从右到左读取时,包含的标志对应于在12414的二进制表示形式中设置的位。
我有以下几点:
public static final int LIMIT_ONE = 1;
public static final int TRADEABLE = (1 << 1);
public static final int SELLABLE = (1 << 2);
public static final int STORABLE = (1 << 3);
public static final int STORABLE_IN_WH = (1 << 4);
public static final int STORABLE_IN_LEGION_WH = (1 << 5);
public static final int BREAKABLE = (1 << 6);
public static final int SOUL_BOUND = (1 << 7);
public static final int UNK9 = (1 << 8);
public static final int UNK10 = (1 << 9);
public static final int UNK11 = (1 << 10);
public static final int CAN_COMPOSITE_WEAPON = (1 << 11);
public static final int BLACK_CLOUD_TRADERS = (1 << 12);
public static final int CAN_SPLIT = (1 << 13);
public static final int UNK15 = (1 << 14);
public static final int UNK16 = (1 << 15);
我想了解如何计算得出以下结果,例如: 12414
我对位掩码的工作原理一无所知,如果有人能给出一些提示并解释它如何达到这个数字,我将不胜感激。
以上是大佬教程为你收集整理的位掩码问题?全部内容,希望文章能够帮你解决位掩码问题?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。