我想在Groovy(或Java当然)中将12位数字扩展为32位。我可以在C / C ++等中找到各种配方,但不能用于Groovy / Java - 有人可以给我一个算法或代码片段吗?
答案 0 :(得分:0)
感谢@harold:
(x << 20) >> 20 or (x ^ 0x800) - 0x800, whichever you like best/is more convenient. The first is easier to understand but it rarely gives further possibilities for simplification