Reputation: 1007
What is the Swift 2+
equivalent for this line of code found in this answer?.
let a:UInt16 = UInt16(bytes[0]) * 256 + UInt16(bytes[1])
Upvotes: 1
Views: 105
Reputation: 22374
by checking that link .. first you have to define bytes array like [UInt8]
let bytes:[UInt8] = [0x01, 0x02]
let a = UInt16(bytes[0]) * 256 + UInt16(bytes[1])
Upvotes: 3