write_float
write_float(f, n, [endian=])
Input: f, n, endian · Output: no output
What it is
Writes n (number) to f (file handle, opened writable/appendable) as a 32-bit IEEE-754 float. endian (string, optional, default "little", or "big") selects byte order.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
write_float(f, n, [endian=]) | f numberWrites n (number) to f (file handle, opened writable/appendable) as a 32-bit IEEE-754 float.n numberWrites n (number) to f (file handle, opened writable/appendable) as a 32-bit IEEE-754 float.endian string, optionalendian (string, optional, default "little", or "big") selects byte order. | no output | — |
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