remove unsigned support

This commit is contained in:
2026-02-04 18:19:50 +01:00
parent 421beeed1e
commit 03ec68cc40
36 changed files with 286 additions and 874 deletions

View File

@@ -3,8 +3,8 @@ package com.infendro.bytes.int
import com.infendro.bytes.ByteOrder
import com.infendro.bytes.ByteOrder.BIG_ENDIAN
fun Int.toByteArray(order: ByteOrder = BIG_ENDIAN): ByteArray =
ByteArray(4).also { copyInto(it, order = order) }
fun Int.toUByteArray(order: ByteOrder = BIG_ENDIAN): UByteArray =
UByteArray(4).also { copyInto(it, order = order) }
fun Int.toByteArray(order: ByteOrder = BIG_ENDIAN): ByteArray {
val result = ByteArray(4)
copyInto(result, order = order)
return result
}

View File

@@ -4,11 +4,7 @@ import com.infendro.bytes.ByteOrder
import com.infendro.bytes.ByteOrder.BIG_ENDIAN
import com.infendro.bytes.ByteOrder.LITTLE_ENDIAN
fun Int.copyInto(
destination: ByteArray,
destinationOffset: Int = 0,
order: ByteOrder = BIG_ENDIAN,
) {
fun Int.copyInto(destination: ByteArray, destinationOffset: Int = 0, order: ByteOrder = BIG_ENDIAN) {
require(destinationOffset in 0..(destination.size - 4))
when (order) {
@@ -26,9 +22,3 @@ fun Int.copyInto(
}
}
}
fun Int.copyInto(
destination: UByteArray,
destinationOffset: Int = 0,
order: ByteOrder = BIG_ENDIAN,
) = copyInto(destination.asByteArray(), destinationOffset, order)

View File

@@ -0,0 +1,5 @@
package com.infendro.bytes.int
operator fun Int.not(): Int {
return inv()
}