In C, I am able to do a trick with numbers:
uint8_t value = 0 int delta = -1 uint8_t result = value + delta /* result will be 0xFF */
Is
All signed and unsigned integer types have a bitPattern: constructor, which creates an unsigned number from a signed (or vice versa) with the same memory representation:
bitPattern:
let delta: Int8 = -1 let result: UInt8 = UInt8(bitPattern: delta) // 0xFF = 255