Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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


let lneg x = x lxor -1

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


To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: