views:

343

answers:

3
+1  Q: 

Bitwise Ops

I'm hooked on bitwise for a new security paradigm I'm creating called VMAC. Variable Matrix Access Control. I want to do logical implication on to bit strings. (1) Before I reinvent the wheel, is there an established shortcut to emulate '->' (logical implication) using AND and OR and NOT or other basic SQL binary operators?

(2) XNOR believe it or not would allow me to cut '->' emulation down to four OPS: NOT, XOR, OR, AND. But it is not widely available. Any known shortcuts to XNOR? I was thinking of something like AND operation on operands plus NOTted operands off the top of my head.

Just trying to avoid echoeureka (reinventing the wheel).

Any comments (3) on efficiency achieved by implementation of bitwise data structures 0n 64-bit platform? Speed on multi-threaded apps using concurrent threads operating on word-size segments of larger data object?

(Sorry, I'm not a computer scientist)

+2  A: 

if A then B is logically equivalent to (not A) or B

ttarchala
+1  A: 

If you're manipulating a bit string then

x -> y

can be expressed in C/C++ (or SQL) as:

~x | y

As far as speed goes, bitwise operators on a single machine word are incredibly fast since they are implemented in a single arithmetic CPU instruction. The performance hit of doing the math should be nearly neglegible in relation to the work of actually retrieving the data.

Eclipse
+1  A: 

Any comments (3) on efficiency achieved by implementation of bitwise data structures 0n 64-bit platform? Speed on multi-threaded apps using concurrent threads operating on word-size segments of larger data object?

I personally haven't given it much thought, but Raymond Chen has some comments.

These are just a few things to take into account when considering whether you should change your fields to bitfields. Sure, bitfields save data memory, but you have to balance it against the cost in code size, debuggability, and reduced multithreading. If your class is going to be instantiated only a few times (and by "a few" I'm thinking less than a few thousand times), then these costs most likely exceed the savings.

Tom Ritter