Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
将小端数转换为大端数的最佳方法是什么?
def i = 0x12345678; def j = 0x78563412; assert i == convert(j) // ?
我知道我可以屏蔽字节并重新排序它们,但什么是更时髦的方式?
好的 ol' Java (SE5+):
assert i == Integer.reverseBytes(j)
但是 Groovier:
def convert = Integer.&reverseBytes assert i == convert(j)