From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id F2065BBC4 for ; Sat, 7 Mar 2009 18:23:28 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AnsBAMs7sknUnwdjjWdsb2JhbACCHZJ1AQEBAQkJCgkPBr1ohAUG X-IronPort-AV: E=Sophos;i="4.38,319,1233529200"; d="scan'208";a="36230083" Received: from relay.pcl-ipout01.plus.net ([212.159.7.99]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 07 Mar 2009 18:23:28 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AuoEAH88sknUnw6R/2dsb2JhbACCHdEThAUG Received: from ptb-relay01.plus.net ([212.159.14.145]) by relay.pcl-ipout01.plus.net with ESMTP; 07 Mar 2009 17:23:28 +0000 Received: from [87.112.234.120] (helo=leper.local) by ptb-relay01.plus.net with esmtp (Exim) id 1Lg0FD-0000ph-MU for caml-list@yquem.inria.fr; Sat, 07 Mar 2009 17:23:27 +0000 From: Jon Harrop Organization: Flying Frog Consultancy Ltd. To: O'Caml Mailing List Subject: Parsing 64-bit ints in 32-bit OCaml Date: Sat, 7 Mar 2009 17:28:56 +0000 User-Agent: KMail/1.9.9 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200903071728.56418.jon@ffconsultancy.com> X-Plusnet-Relay: 06340c4c5b0ab4fd0c0a388ffc264f8a X-Spam: no; 0.00; ocaml:01 failwith:01 ocaml's:01 parser:01 integers:01 frog:98 parsing:01 integer:01 ints:01 functions:01 int:01 int:01 breaks:02 match:02 div:97 I'm just trying to write efficient functions for div and mod by three. I'd like to handle 32- and 64-bit machines with the same code so I tried: let gcd3 = match Sys.word_size with | 32 -> 715827883 | 64 -> 3074457345618258603 | _ -> failwith "Unknown word size" That works perfectly in 64-bit but breaks OCaml's parser in 32-bit, which dies with: Integer literal exceeds the range of representable integers of type int As a workaround, I replaced it with: | 64 -> Int64.to_int 3074457345618258603L Is there a better workaround? -- Dr Jon Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?e