I have some binary data that encodes a two byte value as a signed integer.
bytes[1] = 255 // 0xFF bytes[2] = 251 // 0xF1
extension Int16 { var twoBytes : [UInt8] { let unsignedSelf = UInt16(bitPattern: self) return [UInt8(truncatingIfNeeded: unsignedSelf >> 8), UInt8(truncatingIfNeeded: unsignedSelf)] } } var test : Int16 = -15 test.twoBytes // [255, 241]