[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | skaller <skaller@u...> |
| Subject: | Re: [Caml-list] Int64 overflow checks |
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