shortFrom
Convert 2
bytes from source ByteArray, starting at index offset, 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]
println(Endian.Big.shortFrom(dest, 0))
// 2702
dest.fill(-100)
Endian.Little.pack(source, dest, 0)
println(dest.toList())
// [-114, 10]
println(Endian.Little.shortFrom(dest, 0))
// 2702
Content copied to clipboard
Parameters
source
The ByteArray to access bytes from.
offset
The index to start at when retrieving bytes from source.
See also
Throws
IndexOutOfBoundsException
when not enough bytes are available in array from offset.