Page 1 of 1
'AND', 'OR', 'MOD', 'NOT' and 'XOR' operations
Posted: Wed Oct 21, 2009 12:14 pm
by alexander70
Hi! I have a question about Example 27 (Calulations and use of 'AND', 'OR', 'MOD', 'NOT' and 'XOR' operations.) Where can I read more information on these operators?
Not clear why :
C = ( ( ( A << 2 ) AND 15 ) OR 85 ) >> 1 = 046
D = A * ( ( A MOD 2 ) = 0 ) = 010
E = NOT ( A XOR 60 ) = 201
( if A = 010)
Re: 'AND', 'OR', 'MOD', 'NOT' and 'XOR' operations
Posted: Wed Oct 21, 2009 12:22 pm
by Benj
Hello
This page may be of some help.
http://en.wikipedia.org/wiki/Logic_gate
Also this
http://www.learn-c.com/boolean.htm
The pages I have linked above show single bit truth tables. For 8-bit numbers you have to apply the truth table to each individual bit.
eg
01001101 - 77
AND
10101100 - 172
Equals
00001100 - 12
Re: 'AND', 'OR', 'MOD', 'NOT' and 'XOR' operations
Posted: Wed Oct 21, 2009 12:32 pm
by alexander70
Thank you, I'll study it.
Re: 'AND', 'OR', 'MOD', 'NOT' and 'XOR' operations
Posted: Wed Oct 21, 2009 12:48 pm
by alexander70
There is a description of all operations except the 'MOD'. Where can I learn about the 'MOD' operation?
Re: 'AND', 'OR', 'MOD', 'NOT' and 'XOR' operations
Posted: Wed Oct 21, 2009 2:37 pm
by Benj
Hello
The MOD operation collects the non divisible remainder of a division.
For example
20 MOD 5 = 0
21 MOD 5 = 1
22 MOD 5 = 2
23 MOD 5 = 3
24 MOD 5 = 4
25 MOD 5 = 0
This example would count upwards a single digit at a time and then wrap around to 0 when it reaches the MOD value of 50.
count = (count + 1) MOD 50
Useful for performing loops or for creating counters that rollover at odd values.