扑克牌是52张牌 13级和4级西装
致力于高效的手部表示和评估
A K Q J T 9 8 7 6 5 4 3 2
scdh scdh scdh scdh scdh scdh scdh scdh scdh scdh scdh scdh scdh
52位
As,Ac,Qs Qh,8s,7s 6s
A K Q J T 9 8 7 6 5 4 3 2
scdh scdh scdh scdh scdh scdh scdh scdh scdh scdh scdh scdh scdh
1 1 1 1 1 1 1
它打破9张牌36位 这是最后一组
byte s = 1;
UInt16 spades4 = (UInt16)((s << 12) + (s << 8) + (s << 4) + (s & 0xff));
Debug.WriteLine("Hexadecimal value of {0} is {1} {2}", spades4, String.Format("{0:X}", spades4), Convert.ToString(spades4, 2).PadLeft(16, '0'));
Debug.WriteLine("");
UInt32 spades8 = (UInt32)((s << 28) + (s << 24) + (s << 20) + (s << 16) + (s << 12) + (s << 8) + (s << 4) + (s & 0xff));
Debug.WriteLine("Hexadecimal value of {0} is {1} {2}", spades8, String.Format("{0:X}", spades8), Convert.ToString(spades8, 2).PadLeft(32, '0'));
Debug.WriteLine("");
Int64 spades9 = (Int64)( (s << 30) + (s << 28) + (s << 24) + (s << 20) + (s << 16) + (s << 12) + (s << 8) + (s << 4) + (s & 0xff));
Debug.WriteLine("Hexadecimal value of {0} is {1} {2}", spades9, String.Format("{0:X}", spades9), Convert.ToString(spades9, 2).PadLeft(36, '0'));
Debug.WriteLine("");
// once the shift is up to 31 it breaks - it goes negative
Int64 spades9b = (Int64)((Int64)(s << 31) + (Int64)(s << 28) + (Int64)(s << 24) + (Int64)(s << 20) + (Int64)(s << 16) + (Int64)(s << 12) + (Int64)(s << 8) + (Int64)(s << 4) + (Int64)(s & 0xff));
Debug.WriteLine("Hexadecimal value of {0} is {1} {2}", spades9b, String.Format("{0:X}", spades9b), Convert.ToString(spades9b, 2).PadLeft(36, '0'));
Debug.WriteLine("");
我尝试过UInt64和同样的问题
我认为这是修复 不知道我应该删除这个离开
Int64 spades9b = (Int64)(((Int64)s << 44) | ((Int64)s << 40) | ((Int64)s << 36) | ((Int64)s << 32) | (Int64)(s << 28) | (Int64)(s << 24) | (Int64)(s << 20) | (Int64)(s << 16) | (Int64)(s << 12) | (Int64)(s << 8) | (Int64)(s << 4) | (Int64)(s & 0xff));
Debug.WriteLine("Hexadecimal value of {0} is {1} {2}", spades9b, String.Format("{0:X}", spades9b), Convert.ToString(spades9b, 2).PadLeft(48, '0'));
答案 0 :(得分:0)
s
)以及...... |
代替+
,因为它对于按位操作更为惯用。对于签名的Int64,+可能会导致一些问题,因为最大的正数是范围的一半。一旦两者兼顾,如果仍有问题,请发布新代码以及输出结果。
答案 1 :(得分:0)
解决这些问题的一个简单方法是:
可以将其编码为一个整数。但我不建议。当然,你的问题可能实际是关于内存中值类型的具体实现,而不是关于扑克手,所以我可能完全不在。