shortOf
Convert 2
bytes to a Short.
e.g.
val source = 2702.toShort()
val dest = ByteArray(2) { -100 }
println(dest.toList())
// [-100, -100]
Endian.Big.pack(source, dest, 0)
println(dest.toList())
// [10, -114]
Endian.Big.shortOf(
dest[0],
dest[1],
).let { println(it) }
// 2702
dest.fill(-100)
Endian.Little.pack(source, dest, 0)
println(dest.toList())
// [-114, 10]
Endian.Little.shortOf(
dest[0],
dest[1],
).let { println(it) }
// 2702
Content copied to clipboard