From: skaller <skaller@users.sourceforge.net>
To: Raj B <rajb@rice.edu>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Int64 overflow checks
Date: Tue, 01 May 2007 12:41:51 +1000 [thread overview]
Message-ID: <1177987311.16926.5.camel@rosella.wigram> (raw)
In-Reply-To: <A6FA37DD-F163-4B0C-99E5-4BBED31CD56A@rice.edu>
On Mon, 2007-04-30 at 12:24 -0500, Raj B wrote:
> Hi
>
> I am writing an implementation of the Python programming language in
> OCaml and ran into an interesting issue.
>
> Python allows the programmer to implicitly perform arbitrary-sized
> integer operations by switching internally between its 'int' and
> 'long' types. (which seems to translate to OCaml's int64 and BigInt).
>
> I found an OCaml library on a mailing list which checks for overflow
> in 'normal' 32-bit integer operations. How can I check for overflows
> in int64 operations so I can switch to big-int if that happens?
you use basic maths. For example on addition, you expect
a + b > a
a + b > b
and one of these will be false if you got overflow
(something like that).
--
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net
next prev parent reply other threads:[~2007-05-01 2:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-30 17:24 Raj B
2007-05-01 2:41 ` skaller [this message]
2007-05-01 2:45 ` [Caml-list] " Jon Harrop
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=1177987311.16926.5.camel@rosella.wigram \
--to=skaller@users.sourceforge.net \
--cc=caml-list@yquem.inria.fr \
--cc=rajb@rice.edu \
/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