3
$\begingroup$

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

$\endgroup$
7
$\begingroup$
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}

$\endgroup$
6
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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