caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Nicolas Cannasse" <warplayer@free.fr>
To: <caml-list@inria.fr>, "Christoph Bauer" <c_bauer@informatik.uni-kl.de>
Subject: Re: [Caml-list] Need unsigned int
Date: Wed, 22 Jan 2003 14:55:36 -0000	[thread overview]
Message-ID: <013b01c2c21d$f0b8d3c0$b3580b50@warp> (raw)
In-Reply-To: <m3d6mrej5p.fsf@diebuntekuh.de>

> my program need to calculate a hash key of a matrix (with dimension 8
> x 8).  It is necessary that this calculation is very fast, so my
> program will update the hash key after every small modification of the
> matrix. My problem is that the hash key should be an unsigned int
> or an unsigned long in.
>
> My problem occurs here (Mersenne prime number 2^31-1):
> let big_prim = 2147483647
> val big_prim : int = -1

OCaml does not of unsigned integers.
Using Int64 or Bignum modules as Sven suggested you would be a threat to
your program performances since it involves boxing.

BTW, why do care about the integer sign ?
Only the printer show you -1, but the hardware representation, taking note
that OCaml int are 31 bits, doesn't change between signed and unsigned, does
it ? The only main difference I see is when comparing two signed integers.
Then perhaps something like :

let ui_compare x y =
    x lsr 16 < y lsr 16 || x land 0xFFFF < y land 0xFFFF

Is what you need.

ui_compare 1 2;; // true
ui_compare (-1) 2;; // false

Nicolas Cannasse

-------------------
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


  parent reply	other threads:[~2003-01-22 13:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-20 19:05 Christoph Bauer
2003-01-20 20:58 ` Sven Luther
2003-01-22 14:55 ` Nicolas Cannasse [this message]
2003-01-23 15:00   ` Damien Doligez
2003-01-24  0:39     ` David Chase
2003-01-25 13:50     ` Nicolas Cannasse

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='013b01c2c21d$f0b8d3c0$b3580b50@warp' \
    --to=warplayer@free.fr \
    --cc=c_bauer@informatik.uni-kl.de \
    --cc=caml-list@inria.fr \
    /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).