Kotlin: How to get the value of a bit at a certain position from a Byte?

Viewed 1313

I found solution for java:

public byte getBit(byte value, int position) {
   return (value >> position) & 1;
}

But how it is in Kotlin?

1 Answers

The Kotlin equivalent is:

fun getBit(value: Int, position: Int): Int {
    return (value shr position) and 1;
}
Related