mirror of
https://github.com/mamoe/mirai.git
synced 2025-02-27 12:40:10 +08:00
Add Short.toByteArray()
This commit is contained in:
parent
abe5db2023
commit
c32843fbf3
@ -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
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user