in ocaml I am trying to write a function which takes as an argument a 32 bit unsigned integer. However I am having problems determining the correct identifier to use in the type declaration of the function. By googling I could only find int32. Thanks
Adding to gasche's answer there is a library that provides a module with uint32 type and corresponding operations (including division) - ocaml-uint.
Int32 models signed 32-bit arithmetic. If you're only planning to pass such values around (for example to communicate them to a C API), or use operations that don't depend on signedness, such as add
, mul
, sub
, you can use Int32
just fine. Division and modulo are implemented differently on signed and unsigned numbers, so you shouldn't use those of the Int32 module.
(There was a previous caml-list discussion on this topic.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With