bitwise & doesn’t work with bytes in kotlin
Kolin provides bitwise operator-like infix functions available for Int and Long only. So it’s necessary to convert bytes to ints to perform bitwise ops: val b : Byte = 127 val res = (b.toInt() and 0x0f).toByte() // evaluates to 15 UPDATE: Since Kotlin 1.1 these operations are available directly on Byte. From bitwiseOperations.kt: @SinceKotlin(“1.1”) public … Read more