Join Slack
Powered by
for example, I have a byte array, I want to grab b...
# announcements
t
Travis Griggs
10/23/2019, 5:37 AM
for example, I have a byte array, I want to grab bytes.slice(3 until 5) and get a UShort from them
r
Ruckus
10/23/2019, 1:45 PM
There's a couple ways you could go about it. If you're on the JVM, you could wrap the array in a
ByteBuffer
, specify the order, then read a short (and convert it to a
UShort
). Or you could just do the math directly:
Copy code
(arr[3].toInt() + (arr[4].toInt() shl 8)).toUShort()
Open in Slack
Previous
Next