TempTrack-iOS/TempTrack/Extensions/UInt16+Extensions.swift

21 lines
312 B
Swift
Raw Normal View History

2023-06-08 14:57:40 +02:00
import Foundation
extension UInt16 {
init(high: UInt8, low: UInt8) {
self = UInt16(high) << 8 + UInt16(low)
}
var low: UInt8 {
2023-07-03 13:28:51 +02:00
UInt8(self & 0xFF)
2023-06-08 14:57:40 +02:00
}
var high: UInt8 {
2023-07-03 13:28:51 +02:00
UInt8(self >> 8 & 0xFF)
2023-06-08 14:57:40 +02:00
}
var integer: Int {
.init(self)
}
}