How to dump many floats in binary format so that OCaml can read them in later

I need to write out to disk many floats from a Python script (but that could also be from a C program).
Later, I would like to read them as 32bit floats in OCaml.
What is the format I should use?
I want to use 32bit floats, because 64bit floats would be two times more data.
I guess 32 bits precision is way enough for what I am doing.

I guess some people at Jane Street might know that. :wink:

You can use Int32.float_of_bits to read a single-precision IEEE 754 float into OCaml.



somehow I think of mmap, bigarray, cstruct.

1 Like