How can I get the last two bits from Int8?
Int8
I would like to convert 00110010 to 00000010.
00110010
00000010
Use the bitwise and operator, &:
&
let byte: Int8 = 0b0011_0010 let masked = byte & 0b0000_0011 print(String(masked, radix: 2)) // => 10