can anybody write a program to divide a number by another number using bitwise operators
Probably. What about it?
but i am not getting the logic to divide a number by another number using bitwise operators?? can anybody explain the logic
Can anybody explain the logic of dividing a number by another number using bitwise operators...
areef4u, please dont bump up posts. I have merged your threads.
Following will show you bitwise And & , OR | and XOR ^ operations, And & will copy a bit to the result if it exists in both operands:
main()
{
/* Binary Values */
unsigned int a = 60; /* 60 = 0011 1100 */
unsigned int b = 13; /* 13 = 0000 1101 */
unsigned int c = 0;
c = a & b; /* 12 = 0000 1100 */
}
OR | will copy a bit if it exists in eather operand:
main()
{
/* Binary Values */
unsigned int a = 60; /* 60 = 0011 1100 */
unsigned int b = 13; /* 13 = 0000 1101 */
unsigned int c = 0;
c = a | b; /* 61 = 0011 1101 */
}
XOR ^ copies the bit if it is set in one operand (but not both)
main()
{
/* Binary Values */
unsigned int a = 60; /* 60 = 0011 1100 */
unsigned int b = 13; /* 13 = 0000 1101 */
unsigned int c = 0;
c = a ^ b; /* 49 = 0011 0001 */
}
i want to know the logic, of this example 15/3 = 5, or 16/3 = 5, using bitwise operators. like dividing two numbers using bitwise operators..
i hope u got it.
This isn't exactly a UNIX thing. Try google's first hit for "binary division".
write a program using bitwise operators to divide one number by another.
Pls stop 'leaching' the forums - thread closed!