Philip Dukhov
Int
ByteArray
.toByte()
usePinned
travis
Long
private fun Long.toByteArray(): ByteArray { val data = ByteArray(8) var i = 0 data[i++] = (this ushr 56 and 0xffL).toByte() data[i++] = (this ushr 48 and 0xffL).toByte() data[i++] = (this ushr 40 and 0xffL).toByte() data[i++] = (this ushr 32 and 0xffL).toByte() data[i++] = (this ushr 24 and 0xffL).toByte() data[i++] = (this ushr 16 and 0xffL).toByte() data[i++] = (this ushr 8 and 0xffL).toByte() // ktlint-disable no-multi-spaces data[i] = (this and 0xffL).toByte() // ktlint-disable no-multi-spaces return data }
A modern programming language that makes developers happier.