package com.infendro.bytearray import com.infendro.bytearray.ByteOrder.BIG_ENDIAN fun UInt.toByteArray( order: ByteOrder = BIG_ENDIAN, ): ByteArray { val bytes = ByteArray(4) { i -> val offset = (3 - i) * 8 (this shr offset).toByte() } return bytes.normalize(order) } fun UInt.toUByteArray( order: ByteOrder = BIG_ENDIAN, ): UByteArray { val bytes = UByteArray(4) { i -> val offset = (3 - i) * 8 (this shr offset).toUByte() } return bytes.normalize(order) }