Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to evaluate the following expression:

 11000 AND ( 01011 OR 11011 )

I am able to get the answer on paper. The answer is:

 01011 OR
 11011 =
 11011

Then:

 11000 AND
 11011 =
 11000

I'm new to Mathematica and unsure on how to evaluate this expression and get the same answer using Mathematica. I tried using BitOr and BitAnd built-in functions but I think I'm not using them the right way

share|improve this question
up vote 7 down vote accepted
BitOr[{0, 1, 0, 1, 1}, {1, 1, 0, 1, 1}]

$\ ${1, 1, 0, 1, 1}

BitAnd[{1, 1, 0, 0, 0}, {1, 1, 0, 1, 1}]

$\ ${1, 1, 0, 0, 0}

{1, 1, 0, 0, 0} ~BitAnd~ ({0, 1, 0, 1, 1} ~BitOr~ {1, 1, 0, 1, 1})

$\ ${1, 1, 0, 0, 0}

share|improve this answer

Instead of using the list of digits as suggested by Karsten, you could also explicitly use BaseForm or its infix notation base^^digits:

2^^11000 ~ BitAnd ~ (2^^01011 ~ BitOr ~ 2^^11011) ~ BaseForm ~ 2

which returns $11000_2$ as you expected.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.