A function whose argument is an unsigned 32-bit integer

in ocaml I'm trying to write a function that takes an unsigned 32-bit integer as an argument. However, I am having problems defining the correct identifier to use in a function type declaration. By googling, I could find int32. Thanks

+5
source share
2 answers

Int32 models have signed 32-bit arithmetic. If you are planning to transfer these values (for example, send them to API C) or use operations that do not depend on signature, for example add, mul, subyou can use Int32just fine. Separation and modulation are implemented differently on signed and unsigned numbers, so you should not use them in the Int32 module.

(This section discussed the previous discussion of the caml-list .

+6
source

Adding gasche to the answer is a library that provides a module with type uint32 and the corresponding operations (including division) - ocaml-uint .

+7
source

All Articles