caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Eray Ozkural <exa@kablonet.com.tr>
To: Jacques Garrigue <garrigue@kurims.kyoto-u.ac.jp>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] A grave bug in logical shift right op?
Date: Fri, 7 Nov 2003 08:22:21 +0200	[thread overview]
Message-ID: <200311070822.22104.exa@kablonet.com.tr> (raw)
In-Reply-To: <20031107125304T.garrigue@kurims.kyoto-u.ac.jp>

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


  reply	other threads:[~2003-11-07  6:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-07  3:34 Eray Ozkural
2003-11-07  3:46 ` [Caml-list] " Jed Davis
2003-11-07  3:53 ` [Caml-list] " Jacques Garrigue
2003-11-07  6:22   ` Eray Ozkural [this message]
2003-11-07  3:58 ` Andrew Lenharth

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=200311070822.22104.exa@kablonet.com.tr \
    --to=exa@kablonet.com.tr \
    --cc=caml-list@inria.fr \
    --cc=erayo@cs.bilkent.edu.tr \
    --cc=garrigue@kurims.kyoto-u.ac.jp \
    /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;
as well as URLs for NNTP newsgroup(s).