비트를 마스킹하는 기술 -> 정수를 이진수로 나타내서 연산하는 방식
let initialBits: UInt8 = 0b00001111
let invertedBits = ~initialBits // 11110000
❗️
0b
= 2진수 표현
- 8 진수:
0o
- 16 진수:
0x
let someBits: UInt8 = 0b10110010
let moreBits: UInt8 = 0b01011110
let combinedbits = someBits | moreBits // 11111110
let firstSixBits: UInt8 = 0b11111100
let lastSixBits: UInt8 = 0b00111111
let middleFourBits = firstSixBits & lastSixBits // 00111100
let firstBits: UInt8 = 0b00010100
let otherBits: UInt8 = 0b00000101
let outputBits = firstBits ^ otherBits // 00010001
let initialBits: UInt8 = 0b00010100
let outputBits = initialBits << 2 // 1010000
num = 0
num = -1
00000001
11111110
11111111