Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Get a truth table
Index -> General Programming
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
mirhagk




PostPosted: Sun Jan 02, 2011 10:41 pm   Post subject: Get a truth table

I need an operation to solve this truth table, could be algabraic, or boolean (prefer boolean) and can be a combo

a and b are the inputs
x is the output
y is an overflow flag (for instance 1+1 means x=0 and y=1)


See the truth table below (basically I need no overflow, and x to be equal to b regardless of what's in a)
And no I can't just assign x to equal b (operation takes place in a byte, and individual assignment of bits is not possible in c++, well it probably is, but i'd prefer to not have to dive into assembly.
a b x y
0 0 0 0
0 1 1 0
1 0 0 0
1 1 1 0
Sponsor
Sponsor
Sponsor
sponsor
wtd




PostPosted: Sun Jan 02, 2011 10:53 pm   Post subject: RE:Get a truth table

Bit manipulation most certainly is possible in C++ without resorting to inline assembly.
DemonWasp




PostPosted: Tue Jan 04, 2011 12:26 am   Post subject: RE:Get a truth table

Look up the bitwise operators: | , ^ , and & . That's bitwise-or, bitwise-xor and bitwise-and. Combined with >> and << (shift right, shift left), you can do pretty well whatever you want with your bits.
Display posts from previous:   
   Index -> General Programming
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: