read_double
result = read_double(f, [endian=])
Input: f, endian · Output: result
What it is
Reads a 64-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.
| Code | Input | Output | Description |
result = read_double(f, [endian=]) | f —Reads a 64-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 8 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("sample.bin", "wb")
write_int16(f, -5)
write_uint16(f, 300)
write_uint32(f, 70000)
write_double(f, 3.14159)
close(f)
g = fopen("sample.bin", "rb")
a = read_int16(g)
b = read_uint16(g)
c = read_uint32(g)
d = read_double(g)
close(g)
print("{a} {b} {c} {d}") # -5 300 70000 3.14159
output
-5 300 70000 3.14159
from file-io