17 lines
580 B
Kotlin
17 lines
580 B
Kotlin
package com.infendro.bytes.uint
|
|
|
|
import com.infendro.bytes.ByteOrder
|
|
import com.infendro.bytes.ByteOrder.BIG_ENDIAN
|
|
|
|
fun UInt.toUByteArray(order: ByteOrder = BIG_ENDIAN) =
|
|
UByteArray(4).also { copyInto(it, order = order) }
|
|
|
|
fun UInt.toByteArray(order: ByteOrder = BIG_ENDIAN) =
|
|
ByteArray(4).also { copyInto(it, order = order) }
|
|
|
|
fun UIntArray.toUByteArray(order: ByteOrder = BIG_ENDIAN) =
|
|
UByteArray(size * 4).also { copyInto(it, order = order) }
|
|
|
|
fun UIntArray.toByteArray(order: ByteOrder = BIG_ENDIAN) =
|
|
ByteArray(size * 4).also { copyInto(it, order = order) }
|