Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: Bit operations for beginners

by demerphq (Chancellor)
on Aug 08, 2003 at 18:18 UTC ( #282281=note: print w/replies, xml ) Need Help??

in reply to Bit operations for beginners

I always found it useful to have a chart of all of the boolean operators (and the symbolic logic operators) in one row. This shows all the possibilities at a glance, and also shows how there are "special" operators which can be used to construct all the rest. (NAND and NOR particularly). Another interesting thing to do is to create a binary tree with 4 levels and then mark off each leaf as representing a given operator (or identity), which reveals that there are several potentially useful binary operators which are almost never used.

Anyway, just thought id mention this as it seemed somewhat germane. :-)


<Elian> And I do take a kind of perverse pleasure in having an OO assembly language...

Replies are listed 'Best First'.
Re: Re: Bit operations for beginners
by dorko (Prior) on Aug 08, 2003 at 22:18 UTC
    I also find it useful to have them all in one chart. I also agree with liz about the xor results.

    A B A or B A nor B A xor B A and B A nand B
    0 0 0 1 0 0 1
    0 1 1 0 1 0 1
    1 0 1 0 1 0 1
    1 1 1 0 0 1 0
    * Table created from Prelab 1 for EEL 3342 / Digital Electronics at the UCF, Sept. 17, 1992.
    ** Note: I number my A and B differently than both liz and Cine.


    -- Yeah, I'm a Delt.

      Yep, thats the kind of thing I had in mind. Except that I find it useful to have a chart that has all of the posibile permutations of binary boolean operations. For one it makes it easier to see how you can construct operators from each other. But mostly because I personally find it interesting how the chart of possible operators can be interpreted in different ways, and how complete it is. For instance XOR is commonly used computing and engineering, but rarely in symbolic logic, whereas -> (the conditional) is the opposite.

      Actually I've always found this chart to be fascinating and for lack of a better term, very "deep". The fact that the binary enumeration of 0-15 happens to encode all the binary operators (at least in a boolean sense), along with the unary NOT, identity and empty set, and that you can construct all from some, but not all from every is somewhat amazing to me. I guess its just psychobable but to me theres something special there. The first time I put one together I sort of felt like I had just discovered the boolean table of elements or something. Anyway, I digress. :-)

      DecBinAB0!(A || B)!A && B!AA && !B!BA ^ B!(A && B)A && BA == BB!A || BAA || !BA || B1
      not A
      not B
      1. (*) These are included for completeness. They also have special properties, like A==A or 0, B==B and 1.
      2. These are interesting in that its fairly easy to construct any other operator from either alone.
      3. (**)Im not sure what to call these. Perhaps 'falsifies' as in 'B falsifies A' or 'A falsifies B'. They are the reverse of the conditional or implication (see 7).
      4. (*) Negation
      5. This is logical equality and logical inequality not the traditional perl value equivelence. However using negation you can ensure perl value equivelence as well, ie !$a == !$b or !$a != !$b (the later is better written $a ^ $b)
      6. (*) Identity.
      7. (**)Conditional or implication. A implies B. This is only false when A is True and B is not True. Symbolic logic makes heavy use of this operator, where it can be used to test the truth of assertions like "if A then B".
      8. Commutative and associative. A op B == B op A and ( A op B ) op C == A op ( B op C
      9. )
      10. Transitive and Non Associative. A op B != B op A. If A op B
      11. and B op C then A op C.

        (*) It may be a bit strange to think of these as binary operators, but its not that big of a stretch to do so. And in visualizing the relationships between the other more important operators I find its useful to include them.

        (**) 3 and 7 are interesting in that in effect they are the boolean equivelents of the relational operators.

      Like you I order my chart as a mathematician, engineer or programmer would, and not as a philosopher (who usually use T and F and who "count" from True to False), nor as Cine did. In fact I find his ordering quite unusual, and might even venture to argue that it is plain "wrong" to do so. I certainly think that both of the latter approaches make visualizing the enumeration of the possible input/output states to be much less intuitive. (Actually the whole T/F and ordering thing really got my goat in certain classes in school.)


      <Elian> And I do take a kind of perverse pleasure in having an OO assembly language...
        I used a chart like yours too for a while. After the instructor completed Boolean algebra and tested us on it, we weren't required to use it any more. At that point Karnaugh maps became my good friend! I guess that marks me as an engineer...
        Like you I order my chart as a mathematician, engineer or programmer would ...

        I found the following counting method most useful as it worked best with K-maps. In fact, this is the table I sketched into the front cover of my digital circuits textbook :)

        A B A or B A nor B A xor B A and B A nand B
        0 0 0 1 0 0 1
        0 1 1 0 1 0 1
        1 1 1 0 0 1 0
        1 0 1 0 1 0 1


        -- Yeah, I'm a Delt.

        The A && !B function also has another name apart from gt: >>.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://282281]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2021-07-25 15:11 GMT
Find Nodes?
    Voting Booth?

    No recent polls found