remove unsigned support
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
5
src/commonMain/kotlin/com/infendro/bytes/int/Operator.kt
Normal file
5
src/commonMain/kotlin/com/infendro/bytes/int/Operator.kt
Normal file
@@ -0,0 +1,5 @@
|
||||
package com.infendro.bytes.int
|
||||
|
||||
operator fun Int.not(): Int {
|
||||
return inv()
|
||||
}
|
||||
Reference in New Issue
Block a user