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.
Note that in Kotlin/JS a value obtained by writing an original Float value to a Sink using Sink.writeFloatLe and then reading it back using Source.readFloatLe may not be equal to the original value. Please refer to Float.toBits documentation for details.
Parameters
float
the floating point number to be written.
Throws
when the sink is closed.
when some I/O error occurs.
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
}