C Programming - Bitwise Operators - Discussion

Discussion Forum : Bitwise Operators - True / False Questions (Q.No. 6)
6.
Bitwise & can be used to divide a number by powers of 2
True
False
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
10 comments Page 1 of 1.

Rahul said:   7 years ago
@Ash.

It is written (bitwise &) not left shift bitwise operator.

Sugamathi said:   8 years ago
Could not understand it, please give an explanation.

D.mehul said:   9 years ago
Example:

if((n&(n-1))==0)
printf("num is 2s power\n");
else
printf("not\n");

Pavithra said:   9 years ago
Please give a brief explanation?

Ash said:   1 decade ago
>>,<< we can multiply and divide hence answer should be yes.

Madhu Guddana said:   1 decade ago
@Pranee.

Yes we can do.

Using repetitive addition, we can multiply two numbers.
e.g:- 2*3 = 2+2+2.

Now addition can be done using bit operator as follows:

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;
}

Pranee said:   1 decade ago
Can we multiply two numbers using bitwise operators?

If anyone know the answer please tell me.

Swasti said:   1 decade ago
Bitwise & is used to check wheather a bit is set or not and also used to off d particular bit.

Bit it is not used to divide a number by two.

00000100=4
00000010=2

By result of division we want 00000010 by bitwise operator & we never get only & of 1 and 1 result into 1.

Shyamala said:   1 decade ago
Please do give explanation?

Haridesh said:   1 decade ago
Please give the explanation of this question

Post your comments here:

Your comments will be displayed after verification.