Qu

read_float

Builtin index · File I/O

result = read_float(f, [endian=])

Input: f, endian · Output: result

What it is

Reads a 32-bit IEEE-754 float from f (file handle, opened readable). endian (string, optional, default "little", or "big") selects byte order.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = read_float(f, [endian=])
f —Reads a 32-bit IEEE-754 float from f (file handle, opened readable).
endian string, optionalendian (string, optional, default "little", or "big") selects byte order.
result number
Returns a number, or Nothing if fewer than 4 bytes remain.

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

f = fopen("record.bin", "wb")
write_int32(f, 12345)
write_float(f, 3.5)
close(f)

g = fopen("record.bin", "rb")
n = read_int32(g)
x = read_float(g)
close(g)
print("n = {n}, x = {x}")
output
n = 12345, x = 3.5

from file-io