Commit c32843fb authored by Him188's avatar Him188

Add Short.toByteArray()

parent abe5db20
......@@ -21,6 +21,16 @@ import kotlin.random.nextInt
* 这些函数为内部函数, 可能会改变
*/
/**
* 255 -> 00 FF
*/
fun Short.toByteArray(): ByteArray = with(toInt()) {
byteArrayOf(
(shr(8) and 0xFF).toByte(),
(shr(0) and 0xFF).toByte()
)
}
/**
* 255 -> 00 00 00 FF
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment