caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jed Davis <jdev@panix.com>
To: caml-list@inria.fr
Subject: [Caml-list] Re: A grave bug in logical shift right op?
Date: Thu, 06 Nov 2003 22:46:24 -0500	[thread overview]
Message-ID: <tgnptg4lu27.fsf@cumulus.xlerb.net> (raw)
In-Reply-To: <200311070535.00172.exa@kablonet.com.tr>

Eray Ozkural <exa@kablonet.com.tr> writes:

> I'm using the debian package in testing....
>
> orion:fealn-attack$ ledit ocaml
>         Objective Caml version 3.07+2
>
> # Printf.printf "%X" 0xffffffff;;
> 7FFFFFFF- : unit = ()
> # Printf.printf "%lx" (Int32.of_int 0xffffffff);;
> ffffffff- : unit = ()
> # -1 lsr 24;;
> - : int = 127
> # Int32.shift_right_logical (Int32.of_int (-1)) 24;;
> - : int32 = 255l
>
> What's going on here? Something's eating the most significant bit in
> both hexadecimal output routine and the logical shift right
> operator. Somebody please help me! My cipher isn't working!!!

The size of an int is one bit less than the machine's word size, so 31
bits on a 32-bit arch; this is because the internal representation of
an OCaml value uses the LSB to distinguish between an int (stored in
the top n-1 bits) and some other kind of object.


-- 
Jed Davis <jldavis@cs.oberlin.edu>  Selling of self: http://panix.com/~jdev/rs/
<jdev@panix.com>  PGP<-finger A098:903E:9B9A:DEF4:168F:AA09:BF07:807E:F336:59F9
\   "But life wasn't yes-no, on-off.  Life was shades of gray, and rainbows
/\   not in the order of the spectrum."  -- L. E. Modesitt, Jr., _Adiamante_

-------------------
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  3:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-07  3:34 [Caml-list] " Eray Ozkural
2003-11-07  3:46 ` Jed Davis [this message]
2003-11-07  3:53 ` Jacques Garrigue
2003-11-07  6:22   ` Eray Ozkural
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=tgnptg4lu27.fsf@cumulus.xlerb.net \
    --to=jdev@panix.com \
    --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).