write_int64
write_int64(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 signed 64-bit integer. endian (string, optional, default "little", or "big") selects byte order.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
write_int64(f, n, [endian=]) | f numberWrites n (number) to f (file handle, opened writable/appendable) as a signed 64-bit integer.n numberWrites n (number) to f (file handle, opened writable/appendable) as a signed 64-bit integer.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("sample64.bin", "wb")
write_int64(f, -123456789012)
write_uint64(f, 9007199254740993) # 1 past 2^53 -- the exact-precision edge
close(f)
g = fopen("sample64.bin", "rb")
a = read_int64(g)
b = read_uint64(g)
close(g)
print("{a} {b}") # -123456789012 9007199254740992 -- rounded
M = [1, 2, 3; 4, 5, 6]
write_array("matrix.bin", M, type = "int32")
back = read_array("matrix.bin", type = "int32") -> (2, 3)
print(back) # [1, 2, 3; 4, 5, 6] -- shape recovered via reshape
output
-123456789012 9007199254740992 [1, 2, 3; 4, 5, 6]
from file-io