writeFloat

Writes four bytes of a bit representation of float, in the big-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.writeFloat(12345.678F)

assertContentEquals(byteArrayOf(70, 64, -26, -74), buffer.readByteArray()) 
   //sampleEnd
}