I am writing a program that encodes data in 32 bit ints. Ideally I would like to have 32 bit unsigned ints, but OCaml only has 31 bit signed ints.
I have a large binary file with the data that I will mmap with the
Bigarray.Array1.map_file function.
When I test the following code I am puzzled by the fact that Ocaml doesn't give me back the int in the same format as I wrote it.
Why doesn't OCaml read back data in the same format?
I need to read the data fast without having to manipulate bits beyond the minimum decoding to get my data back from the binary representation.
Thanks.
let test_data = open_out_bin "test.data" in
output_binary_int test_data 1
let data =
let fd = Unix.openfile "test.data" [Unix.O_RDONLY] 0 in
Bigarray.Array1.map_file fd Bigarray.int Bigarray.c_layout
false (-1)