Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
* Logical operators...
@ 1999-08-26 12:11 Hugues CASSE
  1999-08-26 23:18 ` John Prevost
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Hugues CASSE @ 1999-08-26 12:11 UTC (permalink / raw)
  To: CAML

Is there a bug or is there a way to get the correct result...

	# 0xffff0000 lsr 16;;
	- : int = 32767
while
	# 0x0000ffff;;
	- : int = 65535

  This was tested on an UltraSparc under Solaris.

						Thank you.

-- 
------------------------------------------------------------------------
CASSE Hugues             |Heureux qui,comme Ulysse,a fait un beau voyage
IRIT, 1R1, p14	         |Ou comme celui-la qui conquit la Toison,
                         |Et puis est retourne plein d'usage et raison,
PHONE: (33) 561-556-611  |Vivre entre ses parents le reste de son age !
       (poste 73-20)     |                        Les Regrets, Du Bellay
------------------------------------------------------------------------
mailto:casse@irit.fr                    http://www.irit.fr/~Hugues.Casse




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Logical operators...
  1999-08-26 12:11 Logical operators Hugues CASSE
@ 1999-08-26 23:18 ` John Prevost
  1999-08-27  9:07 ` Jean-Christophe Filliatre
  1999-08-27  9:49 ` Reinhard Budde
  2 siblings, 0 replies; 4+ messages in thread
From: John Prevost @ 1999-08-26 23:18 UTC (permalink / raw)
  To: Hugues CASSE; +Cc: CAML

Hugues CASSE <casse@irit.fr> writes:

> Is there a bug or is there a way to get the correct result...
> 
> 	# 0xffff0000 lsr 16;;
> 	- : int = 32767
> while
> 	# 0x0000ffff;;
> 	- : int = 65535

Unfortunately, "native" integers in O'Caml are 31 bits long on 32 bit
machines, and 63 on 54-bit machines.

John.




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Logical operators...
  1999-08-26 12:11 Logical operators Hugues CASSE
  1999-08-26 23:18 ` John Prevost
@ 1999-08-27  9:07 ` Jean-Christophe Filliatre
  1999-08-27  9:49 ` Reinhard Budde
  2 siblings, 0 replies; 4+ messages in thread
From: Jean-Christophe Filliatre @ 1999-08-27  9:07 UTC (permalink / raw)
  To: Hugues CASSE; +Cc: CAML


On a 32 bits architecture, ocaml' integers are signed 31 bits (one bit
is reserved for the GC). Therefore :

======================================================================
# 0xffff0000;;       
- : int = -65536
======================================================================

and that answers your question.

If you really need 32 bits integers, I've written a small 32 bits
integers library, which you can find here :

	 http://www.lri.fr/~filliatr/ftp/ocaml/int32/

You  can use  it freely,  and even  adapt it  to unsigned  integers if
necessary. Of course, there is a lack of performance compared to ocaml
integers.

Best regards,
-- 
Jean-Christophe FILLIATRE
  mailto:Jean-Christophe.Filliatre@lri.fr
  http://www.lri.fr/~filliatr


In his message of Thu August 26, 1999, Hugues CASSE writes: 
> Is there a bug or is there a way to get the correct result...
> 
> 	# 0xffff0000 lsr 16;;
> 	- : int = 32767
> while
> 	# 0x0000ffff;;
> 	- : int = 65535




^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Logical operators...
  1999-08-26 12:11 Logical operators Hugues CASSE
  1999-08-26 23:18 ` John Prevost
  1999-08-27  9:07 ` Jean-Christophe Filliatre
@ 1999-08-27  9:49 ` Reinhard Budde
  2 siblings, 0 replies; 4+ messages in thread
From: Reinhard Budde @ 1999-08-27  9:49 UTC (permalink / raw)
  To: CAML

Hugues CASSE wrote:
> Is there a bug or is there a way to get the correct result...
>         # 0xffff0000 lsr 16;;
>         - : int = 32767
> while
>         # 0x0000ffff;;
>         - : int = 65535
ints are represented with 31 bits. This is sometimes suprising:

        Objective Caml version 2.01
# 0xffff0000;;
- : int = -65536
# 0x7fff0000;;
- : int = -65536

Consequently:
# 0xffff0000 = 0x7fff0000;;
- : bool = true

0xffff0000 ist not represented in ocaml as you expected

Reinhard
--------------
Reinhard Budde  reinhard.budde@gmd.de
GMD          -  German National Research Center for Information
Technology
AiS          -  Autonomous intelligent Systems
D-53754 St.Augustin     tel: +2241-14-2417,fax: +2241-14-2324




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1999-08-28 17:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-08-26 12:11 Logical operators Hugues CASSE
1999-08-26 23:18 ` John Prevost
1999-08-27  9:07 ` Jean-Christophe Filliatre
1999-08-27  9:49 ` Reinhard Budde

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox