readFloat

Removes four bytes from this source and returns a floating point number with type Float composed of it according to the big-endian order.

The Float.Companion.fromBits function is used for decoding bytes into Float.

Note that in Kotlin/JS a value obtained by writing an original Float value to a Sink using Sink.writeFloat and then reading it back using Source.readFloat may not be equal to the original value. Please refer to Float.Companion.fromBits documentation for details.

Throws

when there are not enough data to read an unsigned int value.

when the source is closed.

when some I/O error occurs.

Samples

import kotlinx.io.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   val buffer = Buffer()
buffer.write(byteArrayOf(70, 64, -26, -74))
assertEquals(12345.678F.toBits(), buffer.readFloat().toBits()) 
   //sampleEnd
}