We help IT Professionals succeed at work.
Get Started

help in these Bit operations...

not_an_xpert asked
Last Modified: 2010-04-15
Hello all,
Recently I had hit upon a document on efficient C optimisations... most of them are bit manipulation operations
as i was going thro' the doc. i'd some doubts.. cud the experts throw some light on these

1) (x+y) equals ((x&y)+(x|y)) equals ((x^y)+2*(x&y)).  How is this possible
2) Given 2's complement integer values x and y, the minimum can be computed without any branches
     as x+(((y-x)>>(WORDBITS-1))&(y-x)).  how can they arrive on this
3) Similarly  Given a 2's complement binary integer value x, (x&-x) is the least significant 1 bit.

It s not any Home work question(S).
I can provide the doc. if reqd.

Watch Question
Data Warehouse / Database Architect
This problem has been solved!
Unlock 1 Answer and 10 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE