<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2003/01/2f8b8c3e56cbc57ad0828a8c4c361f8a"
  from="Nicolas Cannasse &lt;warplayer@f...&gt;"
  author="Nicolas Cannasse"
  date="2003-01-22T13:51:49"
  subject="Re: [Caml-list] Need unsigned int"
  prev="2003/01/f781fbd10809682f5020b87923bff572"
  next="2003/01/a81f1cb20b0c89d47609694a59035408"
  prev-in-thread="2003/01/a7f0ca55dfc7972117511c4551434184"
  next-in-thread="2003/01/4d220c5232a3b748cd9592002eec3313"
  prev-thread="2003/01/a4cffb254f58984e709674a57450d264"
  next-thread="2003/01/18adbbf91ec34b35351de3a8ecc5092f"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] Need unsigned int">
<msg 
  url="2003/01/72c455ab961d117e66091b9e50b158a7"
  from="Christoph Bauer &lt;c_bauer@i...&gt;"
  author="Christoph Bauer"
  date="2003-01-20T19:06:30"
  subject="[Caml-list] Need unsigned int">
<msg 
  url="2003/01/a7f0ca55dfc7972117511c4551434184"
  from="Sven Luther &lt;luther@d...&gt;"
  author="Sven Luther"
  date="2003-01-20T20:58:38"
  subject="Re: [Caml-list] Need unsigned int">
</msg>
<msg 
  url="2003/01/2f8b8c3e56cbc57ad0828a8c4c361f8a"
  from="Nicolas Cannasse &lt;warplayer@f...&gt;"
  author="Nicolas Cannasse"
  date="2003-01-22T13:51:49"
  subject="Re: [Caml-list] Need unsigned int">
<msg 
  url="2003/01/4d220c5232a3b748cd9592002eec3313"
  from="Damien Doligez &lt;damien.doligez@i...&gt;"
  author="Damien Doligez"
  date="2003-01-23T15:01:17"
  subject="Re: [Caml-list] Need unsigned int">
<msg 
  url="2003/01/be461c4ff942cdbf26f01b18b78f15db"
  from="David Chase &lt;chase@w...&gt;"
  author="David Chase"
  date="2003-01-24T00:39:59"
  subject="Re: [Caml-list] Need unsigned int">
</msg>
<msg 
  url="2003/01/8ee94a5b5e46b261b7599c6003b3a18b"
  from="Nicolas Cannasse &lt;warplayer@f...&gt;"
  author="Nicolas Cannasse"
  date="2003-01-25T12:46:27"
  subject="Re: [Caml-list] Need unsigned int">
</msg>
</msg>
</msg>
</msg>
</thread>

<contents>
&gt; my program need to calculate a hash key of a matrix (with dimension 8
&gt; x 8).  It is necessary that this calculation is very fast, so my
&gt; program will update the hash key after every small modification of the
&gt; matrix. My problem is that the hash key should be an unsigned int
&gt; or an unsigned long in.
&gt;
&gt; My problem occurs here (Mersenne prime number 2^31-1):
&gt; let big_prim = 2147483647
&gt; 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 &lt; y lsr 16 || x land 0xFFFF &lt; 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

</contents>

</message>

