# C Programming - Bitwise Operators - Discussion

### Discussion :: Bitwise Operators - Yes / No Questions (Q.No.6)

6.

Bitwise can be used to perform addition and subtraction.

 [A]. Yes [B]. No

Explanation:

No answer description available for this question.

 Cheran said: (Jul 13, 2011) Bitwise operators can be used for multiplication and division only.

 Dmitri said: (Aug 26, 2011) If bitwise operators can't be used for addition or subtraction, why can the hardware do it? It uses boolean operations on individual bits... Also try the following function (which does addition with bitwise operators): int bitadd(int x, int y) { int z = 0, c; do { z = x ^ y; c = (x & y) << 1; x = z; y = c; } while (c); return z; }

 Atul said: (May 29, 2012) A big circuit inside the computer is made up of adder and subtracters which can perform all the operations like addition, multiplication, subtraction and division so how it can't be performed Dmitri has given good example above.

 David said: (Jan 10, 2014) Whoever wrote this should swot up of course you can do bitwise addition and subtraction. unsigned int myAdd(unsigned int a, unsigned int b) { unsigned int carry = a & b; unsigned int result = a ^ b; while(carry != 0) { unsigned int shiftedcarry = carry << 1; carry = result & shiftedcarry; result ^= shiftedcarry; } return result; }

 Saumya said: (Sep 22, 2017) The Answer should be A. Because we can perform addition as well as subtraction using bitwise XOR.