3

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

Karsten7
  • 27,448
  • 5
  • 73
  • 134
wa7d
  • 45
  • 5

2 Answers2

7
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}

Karsten7
  • 27,448
  • 5
  • 73
  • 134
6

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.

MarcoB
  • 67,153
  • 18
  • 91
  • 189