intOf

abstract fun intOf(b0: Byte, b1: Byte, b2: Byte, b3: Byte): Int(source)

Convert 4 bytes to an Int.

e.g.

val source = -77362181
val dest = ByteArray(4) { -100 }
println(dest.toList())
// [-100, -100, -100, -100]

Endian.Big.pack(source, dest, 0)
println(dest.toList())
// [-5, 99, -117, -5]
Endian.Big.intOf(
    dest[0],
    dest[1],
    dest[2],
    dest[3],
).let { println(it) }
// -77362181
dest.fill(-100)

Endian.Little.pack(source, dest, 0)
println(dest.toList())
// [-5, -117, 99, -5]
Endian.Little.intOf(
    dest[0],
    dest[1],
    dest[2],
    dest[3],
).let { println(it) }
// -77362181

See also