English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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: 2003-02-21 (23:02)
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 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