Module Base__.Int_conversions
val int_to_int32 : int -> int32 optionOcaml has the following integer types, with the following bit widths on 32-bit and 64-bit architectures.
arch arch type 32b 64b ---------------------- int 31 63 (32 when compiled to JavaScript) nativeint 32 64 int32 32 32 int64 64 64In both cases, the following inequalities hold:
width(int) < width(nativeint) && width(int32) <= width(nativeint) <= width(int64)The conversion functions come in one of two flavors.
If width(foo) <= width(bar) on both 32-bit and 64-bit architectures, then we have
val foo_to_bar : foo -> barotherwise we have
val foo_to_bar : foo -> bar option val foo_to_bar_exn : foo -> bar
val int_to_int32_exn : int -> int32val int_to_int32_trunc : int -> int32val int_to_int64 : int -> int64val int_to_nativeint : int -> nativeintval int32_to_int : int32 -> int optionval int32_to_int_exn : int32 -> intval int32_to_int_trunc : int32 -> intval int32_to_int64 : int32 -> int64val int32_to_nativeint : int32 -> nativeintval int64_to_int : int64 -> int optionval int64_to_int_exn : int64 -> intval int64_to_int_trunc : int64 -> intval int64_to_int32 : int64 -> int32 optionval int64_to_int32_exn : int64 -> int32val int64_to_int32_trunc : int64 -> int32val int64_to_nativeint : int64 -> nativeint optionval int64_to_nativeint_exn : int64 -> nativeintval int64_to_nativeint_trunc : int64 -> nativeintval int64_fit_on_int63_exn : int64 -> unitval int64_is_representable_as_int63 : int64 -> boolval nativeint_to_int : nativeint -> int optionval nativeint_to_int_exn : nativeint -> intval nativeint_to_int_trunc : nativeint -> intval nativeint_to_int32 : nativeint -> int32 optionval nativeint_to_int32_exn : nativeint -> int32val nativeint_to_int32_trunc : nativeint -> int32val nativeint_to_int64 : nativeint -> int64val num_bits_int : intval num_bits_int32 : intval num_bits_int64 : intval num_bits_nativeint : int
module Make : functor (I : sig ... end) -> sig ... endhuman-friendly string (and possibly sexp) conversions
module Make_hex : functor (I : sig ... end) -> Base__.Int_intf.Hexable with type t := I.tin the output,
to_string,of_string,sexp_of_t, andt_of_sexpconvert betweentand signed hexadecimal with an optional "0x" or "0X" prefix.
val sexp_of_int_style : [ `No_underscores | `Underscores ] Caml.refglobal ref affecting whether the
sexp_of_treturned byMakeis consistent with theto_stringinput or theto_string_humoutput
val insert_delimiter_every : string -> delimiter:char -> chars_per_delimiter:int -> stringutility for defining to_string_hum on numeric types -- takes a string matching (-|+)?
0-9a-fA-F+ and putsdelimitereverychars_per_delimitercharacters starting from the right.