longOf

abstract fun longOf(b0: Byte, b1: Byte, b2: Byte, b3: Byte, b4: Byte, b5: Byte, b6: Byte, b7: Byte): Long(source)

Convert 8 bytes to a Long.

e.g.

val source = 9223372034707292160L
val dest = ByteArray(8) { -100 }
println(dest.toList())
// [-100, -100, -100, -100, -100, -100, -100, -100]

Endian.Big.pack(source, dest, 0)
println(dest.toList())
// [127, -1, -1, -1, -128, 0, 0, 0]
Endian.Big.longOf(
    dest[0],
    dest[1],
    dest[2],
    dest[3],
    dest[4],
    dest[5],
    dest[6],
    dest[7],
).let { println(it) }
// 9223372034707292160
dest.fill(-100)

Endian.Little.pack(source, dest, 0)
println(dest.toList())
// [0, 0, 0, -128, -1, -1, -1, 127]
Endian.Little.longOf(
    dest[0],
    dest[1],
    dest[2],
    dest[3],
    dest[4],
    dest[5],
    dest[6],
    dest[7],
).let { println(it) }
// 9223372034707292160

See also