I am trying to convert a large base-10 number to base-16 and then to hex. The error I am getting is Ocaml is saying the integer is too big.
utop # let large_int = 11515195063862318899931685488813747395775516287289682636499965282714637259206269 ;;Error: Integer literal exceeds the range of representable integers of type int
I tried using Int64 as well and a similar issue.
utop # let large_int = Int64.of_string "11515195063862318899931685488813747395775516287289682636499965282714637259206269";; Exception: Failure "Int64.of_string".
This is the larger code I am trying to make work. It works as expected with the example integer below.
(* convert from base10_to_base16 *)let rec split_digits n = if n = 0 then [] else let (d, rest) = n mod 256, n / 256 in d :: split_digits restlet decode_base10 message = let bytes_arr = List.rev (split_digits message) in let decoded_message = String.concat "" (List.map (fun x -> String.make 1 (Char.chr x)) bytes_arr) in decoded_messagelet base10_message = 310400273487 (* base-10 number *)let decoded_message = decode_base10 base10_message