Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] A grave bug in logical shift right op?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ 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) <>
Comp. Sci. Dept., Bilkent University, Ankara  KDE Project:
www:  Malfunction:
GPG public key fingerprint: 360C 852F 88B0 A745 F31B  EA0F 7C07 AE16 874D 539C

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: