All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jvmMain.kotlinx.io.bits.ByteOrderJVM.kt Maven / Gradle / Ivy

There is a newer version: 0.1.16
Show newest version
package kotlinx.io.bits

/**
 * Reverse number's byte order
 */
@Suppress("NOTHING_TO_INLINE")
actual inline fun Short.reverseByteOrder(): Short = java.lang.Short.reverseBytes(this)


/**
 * Reverse number's byte order
 */
@Suppress("NOTHING_TO_INLINE")
actual inline fun Int.reverseByteOrder(): Int = java.lang.Integer.reverseBytes(this)


/**
 * Reverse number's byte order
 */
@Suppress("NOTHING_TO_INLINE")
actual inline fun Long.reverseByteOrder(): Long = java.lang.Long.reverseBytes(this)


/**
 * Reverse number's byte order
 */
@Suppress("NOTHING_TO_INLINE")
actual inline fun Float.reverseByteOrder(): Float =
    java.lang.Float.intBitsToFloat(
        java.lang.Integer.reverseBytes(
            java.lang.Float.floatToRawIntBits(this)
        )
    )

/**
 * Reverse number's byte order
 */
@Suppress("NOTHING_TO_INLINE")
actual inline fun Double.reverseByteOrder(): Double =
    java.lang.Double.longBitsToDouble(
        java.lang.Long.reverseBytes(
            java.lang.Double.doubleToRawLongBits(this)
        )
    )





© 2015 - 2025 Weber Informatics LLC | Privacy Policy