Big Chungus
07/25/2020, 10:43 AMcaffeine
07/25/2020, 11:23 AMBig Chungus
07/26/2020, 8:41 AMcaffeine
07/30/2020, 12:06 PMfun Long.toInts() =
Int.fromBytes(this[0],this[1],this[2],this[3]) to
Int.fromBytes(this[4],this[5],this[6],this[7])
Also, if you don't want to use my library you can use something like this:
fun Long.toInts():Pair<Int,Int>{
val b1=((this ushr (56 - 8 * 0)) and 0xFF).toByte()
val b2=((this ushr (56 - 8 * 1)) and 0xFF).toByte()
val b3=((this ushr (56 - 8 * 2)) and 0xFF).toByte()
val b4=((this ushr (56 - 8 * 3)) and 0xFF).toByte()
val b5=((this ushr (56 - 8 * 4)) and 0xFF).toByte()
val b6=((this ushr (56 - 8 * 5)) and 0xFF).toByte()
val b7=((this ushr (56 - 8 * 6)) and 0xFF).toByte()
val b8=((this ushr (56 - 8 * 7)) and 0xFF).toByte()
val int1 = ((b1.toInt() and 0xFF) shl 24) +
((b2.toInt() and 0xFF) shl 16) +
((b3.toInt() and 0xFF) shl 8) +
((b4.toInt() and 0xFF) shl 0)
val int2 = ((b5.toInt() and 0xFF) shl 24) +
((b6.toInt() and 0xFF) shl 16) +
((b7.toInt() and 0xFF) shl 8) +
((b8.toInt() and 0xFF) shl 0)
return int1 to int2
}