21 lines
318 B
Swift
21 lines
318 B
Swift
|
import Foundation
|
||
|
|
||
|
extension UInt16 {
|
||
|
|
||
|
init(high: UInt8, low: UInt8) {
|
||
|
self = UInt16(high) << 8 + UInt16(low)
|
||
|
}
|
||
|
|
||
|
var low: UInt8 {
|
||
|
UInt8(clamping: self)
|
||
|
}
|
||
|
|
||
|
var high: UInt8 {
|
||
|
UInt8(clamping: self >> 8)
|
||
|
}
|
||
|
|
||
|
var integer: Int {
|
||
|
.init(self)
|
||
|
}
|
||
|
}
|