我在尝试将Int64转换为字节数组时遇到问题。 value
为否定时,应用失败。
这就是我在操场上的内容:
let value: Int64 = -1
let byte1: UInt8 = UInt8((value >> 56) | Int64(0xFF))
let byte2: UInt8 = UInt8((value >> 48) | Int64(0xFF))
let byte3: UInt8 = UInt8((value >> 40) | Int64(0xFF))
let byte4: UInt8 = UInt8((value >> 32) | Int64(0xFF))
let byte5: UInt8 = UInt8((value >> 24) | Int64(0xFF))
let byte6: UInt8 = UInt8((value >> 16) | Int64(0xFF))
let byte7: UInt8 = UInt8((value >> 8) | Int64(0xFF))
let byte8: UInt8 = UInt8(value & Int64(0xFF))
我不确定(现在无法检查)但是相同的代码在c ++ - port中工作。