Thread: exercise clarification truth table

  1. #1
    Registered User
    Join Date
    Jul 2003

    exercise clarification truth table

    Here is the exercise which I need a little clarification on.

    Write a table of values for the bitwise logical operations for all combinations of 0 and 1 operands.

    Sounds simple
    but he wants us to use an enumeration (which seems kind of pointless to me) I came up with this form
    enum state_operands{bit_operand_result=0, bit_operand_one=1,  bit_operand_two=2}
    //now can I just
    int state=bit_operand_result;
    vector<state_operands> truth_table;
    does this appear about correct I think this logic is wrong because I am not sure exactly what he means.

    does he want
    bool_result=bool_one & bool_two;

    or somthing like I implemented.
    I realize my implementation is wrong because it does not properly set the result bit.

    How would I get a result in such an implementation?

    This is C++ Programming Language Third Edition. 6.6 #4 and he refers to 6.2.4 the explanation on bitwise enumerations.
    Last edited by curlious; 12-18-2003 at 01:57 PM.

  2. #2
    Registered User
    Join Date
    Apr 2003
    Your enumerations obviously aren't going to work because 1 and 2 are both true, and a truth table consists of all combinations of true and false.

    I would think that "result" wouldn't be an enumeration, rather only your two states 'T' and 'F'. It would be clearer what you were trying to do if you posted the explanation of bitwise enumerations for the exercise. Barring that, you should probably reread the section a few times.
    Last edited by 7stud; 12-18-2003 at 10:40 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Writing array, to file
    By zootreeves in forum C Programming
    Replies: 9
    Last Post: 09-08-2007, 05:06 PM
  2. XOR truth table
    By swgh in forum C++ Programming
    Replies: 4
    Last Post: 02-08-2006, 10:12 AM
  3. program to construct a truth table
    By ashok varma in forum C Programming
    Replies: 2
    Last Post: 08-04-2005, 10:53 AM
  4. logic circuit truth table
    By botakis in forum C Programming
    Replies: 3
    Last Post: 11-18-2004, 11:02 AM
  5. Programming a Truth Table
    By Nitelite in forum C Programming
    Replies: 2
    Last Post: 09-26-2002, 01:49 PM