I must be missing something simple here. I have an application I'm writing and having trouble with shifts and 64 bit unsigned integers. Here's some playground code:
import UIKit
let a: UInt64 = 0xFFFFFFFF00000000
let b: UInt64 = 0x0000000000000000
print(String(format: "a = 0x%016X", a))
print(String(format: "b = 0x%016X", b))
print(String(format: "a | b = 0x%016X", a | b))
It produces this output:
a = 0x0000000000000000
b = 0x0000000000000000
a | b = 0x0000000000000000
Why is "a" not equal to 0xFFFFFFFF00000000?
I'm using XCode 14.3.1.
I also found issues shifting a byte into the upper 32 bits of a UInt64:
let c: UInt64 = 0x00000000000000FF
let d: UInt64 = 0x0000000000000000
print(String(format: "c = 0x%016X", c))
print(String(format: "d = 0x%016X", d))
print(String(format: "d | (c << 32) = 0x%016X", d | (c << 32)))
This produces this output:
c = 0x00000000000000FF
d = 0x0000000000000000
d | (c << 32) = 0x0000000000000000