Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Bitwise negation operator?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Brian Hurt <brian.hurt@q...>
Subject: [Caml-list] Bitwise negation operator?

Is there a bitwise negation operator I'm just missing?  I'm looking for 
the equivelent of C's ~ operator.  In Ocaml, it would have type int->int.  
In two's complement, I can implement this as either

let lneg x = (-x) - 1

or:

let lneg x = x lxor -1

I dislike depending upon being two's complement for bitwise negation.

Brian


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