Asked • 05/24/19

Why is (a | b ) equivalent to a - (a & b) + b?

I was looking for a way to do a BITOR() with an Oracle database and came across a suggestion to just use BITAND() instead, replacing BITOR(a,b) with a + b - BITAND(a,b).I tested it by hand a few times and verified it seems to work for all binary numbers I could think of, but I can't think out quick mathematical proof of why this is correct. Could somebody enlighten me?

2 Answers By Expert Tutors


Kaitlyn R. answered • 05/24/19

5.0 (103)

Adjunct Professor in Computer Science

Zachary S. answered • 05/24/19

5 (6)

Software Engineer after I graduate in 1 semester

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.


Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.