From: Jon Harrop <jon@ffconsultancy.com>
To: O'Caml Mailing List <caml-list@yquem.inria.fr>
Subject: Parsing 64-bit ints in 32-bit OCaml
Date: Sat, 7 Mar 2009 17:28:56 +0000 [thread overview]
Message-ID: <200903071728.56418.jon@ffconsultancy.com> (raw)
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
next reply other threads:[~2009-03-07 17:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-07 17:28 Jon Harrop [this message]
2009-03-07 18:12 ` [Caml-list] " Jérémie Dimino
2009-03-16 21:58 ` Jean-Christophe Filliâtre
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200903071728.56418.jon@ffconsultancy.com \
--to=jon@ffconsultancy.com \
--cc=caml-list@yquem.inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox