Files
bytes.kt/src/commonMain/kotlin/com/infendro/bytes/uint/Conversion.kt
2026-01-15 14:56:46 +01:00

11 lines
359 B
Kotlin

package com.infendro.bytes.uint
import com.infendro.bytes.ByteOrder
import com.infendro.bytes.ByteOrder.BIG_ENDIAN
fun UInt.toByteArray(order: ByteOrder = BIG_ENDIAN): ByteArray =
ByteArray(4).also { copyInto(it, order = order) }
fun UInt.toUByteArray(order: ByteOrder = BIG_ENDIAN): UByteArray =
UByteArray(4).also { copyInto(it, order = order) }