Use the octal dump utility, named od
on Unix systems; it supports parsing floating-point binary representations as well.
Specifically, and letting N1 = n_1 * 4, N2 = n_2 * 4 and N3 = N2 - N1, invoke:
od -An -w4 -tf4 -j N1 -N N3 file_with_floats.bin
to get something like:
-123.456
inf
111.222
for a file with three 4-byte float values.
Explanation:
-w4
: Print the dumped values of 4 bytes per line (i.e. one float value)
-An
: No prefixing each line with the starting offset into the file
-tf4
: Floating-point format, 4 bytes per value
-j N1
: Skip N1 bytes
-N N3
: Dump N3 bytes
If you want to print your file in C columns use 4*C as the argument to -w
, e.g. -w20
will give you 5 columns per line.