上一题是将两个Int32
编码成一个Int64
[ C# - Making one Int64 from two Int32s
问题:如何将一个Int64
解码回两个Int32
?
最佳答案
像这样:
long x = ...;
int a = (int) (x & 0xffffffffL);
int b = (int) (x >> 32);
第一种形式的掩码可能是不必要的......我永远记不起有关缩小转换和带符号值的细节,这就是我将其包括在内的原因:)
关于c# - 如何将一个 Int64 解码回两个 Int32?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3616400/