Browse thread
[Caml-list] A grave bug in logical shift right op?
-
Eray Ozkural
- Jed Davis
-
Jacques Garrigue
- Eray Ozkural
- Andrew Lenharth
[
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: | Eray Ozkural <exa@k...> |
| Subject: | Re: [Caml-list] A grave bug in logical shift right op? |
Excuse me for forgetting this fact about the ocaml int type. Having been too accustomed to C/C++, I must have conditioned myself into thinking int couldn't possibly be 31 bits. I swear I had learnt it sometime in the past only to forget it :) Thanks for the clarification. On Friday 07 November 2003 05:53, Jacques Garrigue wrote: > Sure, the int type has only 31 bits. In good math, > (2 ^ 31 - 1) quo 2 ^ 24 is 127, as far as I know. > > Note that the problem with your first example has already been > discussed. A litteral bigger than the biggest possible integer should > probably trigger an error/exception. > A bit more curions is your second example: since > 0xffffffff = 0x7fffffff = -1, converting it to int32 gives -1l (the > 32-bit value for -1), which happens to be 0xffffffffl. > > If you want to do 32-bit computations, you must use only 32-bit > integers. This shouldn't be too inefficient as long as you use loops > rather than function calls (the same recommandations as for floats > apply, I believe). > > Jacques Garrigue -- Eray Ozkural (exa) <erayo@cs.bilkent.edu.tr> Comp. Sci. Dept., Bilkent University, Ankara KDE Project: http://www.kde.org www: http://www.cs.bilkent.edu.tr/~erayo Malfunction: http://mp3.com/ariza GPG public key fingerprint: 360C 852F 88B0 A745 F31B EA0F 7C07 AE16 874D 539C ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners