read_int
result = read_int(f, [bytes=4], [signed=true], [endian="little"])
Input: f, bytes, signed, endian · Output: result
What it is
The width-as-a-value counterpart of the fixed-width family above: reads bytes (a number, 1/2/4/8 only) from f (file handle, opened readable) and decodes them as an integer, with signed (boolean) and endian (string) chosen at runtime rather than by which function you called. Reach for it when a format declares its field width in a header instead of in its spec.
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = read_int(f, [bytes=4], [signed=true], [endian="little"]) | f number, boolean, or stringnot documented yetbytes number, boolean, or string, optional (default 4)not documented yetsigned number, boolean, or string, optional (default true)not documented yetendian number, boolean, or string, optional (default "little")not documented yet | result number | Returns a number, or Nothing if fewer than bytes bytes remain. Every number here is an f64, so an 8-byte value above 2^53 comes back rounded — the same ceiling read_int64 documents. |
Examples
No documentation example calls this form yet. The File I/O chapter is where one belongs.