writeFloatLe
Writes four bytes of a bit representation of float, in the little-endian order, to this sink. Bit representation of the float corresponds to the IEEE 754 floating-point "single format" bit layout.
To obtain a bit representation, the Float.toBits function is used.
Should be used with care when working with special values (like NaN
) as bit patterns obtained for Float.NaN may vary depending on a platform.
Parameters
float
the floating point number to be written.
Throws
when the sink is closed.
Samples
import kotlinx.io.*
import kotlin.test.*
fun main() {
//sampleStart
val buffer = Buffer()
buffer.writeFloatLe(12345.678F)
assertContentEquals(byteArrayOf(-74, -26, 64, 70), buffer.readByteArray())
//sampleEnd
}