This commit is contained in:
2025-12-12 21:20:44 +01:00
parent be9a8a4369
commit 01327ef4b2
12 changed files with 197 additions and 179 deletions

View File

@@ -9,17 +9,7 @@ fun UInt.toByteArray(
val offset = (3 - i) * 8
(this shr offset).toByte()
}
return order.normalize(bytes)
}
fun UIntArray.toByteArray(
order: ByteOrder = BIG_ENDIAN,
): ByteArray {
val bytes = mutableListOf<Byte>()
for (n in this) {
bytes += n.toByteArray(order).toList()
}
return bytes.toByteArray()
return bytes.normalize(order)
}
fun UInt.toUByteArray(
@@ -29,15 +19,5 @@ fun UInt.toUByteArray(
val offset = (3 - i) * 8
(this shr offset).toUByte()
}
return order.normalize(bytes)
}
fun UIntArray.toUByteArray(
order: ByteOrder = BIG_ENDIAN,
): UByteArray {
val bytes = mutableListOf<UByte>()
for (n in this) {
bytes += n.toUByteArray(order)
}
return bytes.toUByteArray()
return bytes.normalize(order)
}