Length of int in OCaml?

What is the length of int in OCaml? It is said that int in OCaml is 31. But I get this:

# (1 lsl 33);;
- : int = 8589934592

8589934592 is larger than 2^31.

On my laptop (64-bit Fedora Linux), the int in OCaml is 63 bits. The code (count1s counts the number of bit 1s in an integer):

let rec count1s x =
    match (x lsr 1, x land 1) with
    | 0, n -> n
    | y, n -> n + count1s y

count1s (-1);;
Answered by anonymous.

Leave a Reply

Your email address will not be published. Required fields are marked *