Member-only story

Bitwise Operations

randerson112358
3 min readDec 14, 2017

--

AND, OR, XOR

Source: http://eeenthusiast.com/boolean-logic-bitwise-operators-tutorial-and-walkthrough-in-swift/

Bit is short for binary digit. It is one of two digits, either a ‘0' or a ‘1’. A bitwise operation operates on one or more bits. There are many types of operations that can be used on bits for example AND, OR, and XOR operations can all be used on bits.

Let’s take a look at some of these operations and see how they manipulate bits.

AND Operation

A bitwise ‘AND’ operation can be performed by multiplying the bits together to get the result. Another way to do this operation is if you see a 0 the result is 0 otherwise the result is 1. For example let’s AND two binary numbers together and see the result. We will use the binary numbers 1010, and 1101. 1010 is 10 in the Arabic base ten numeral system (the number system you are probably used to) , and 1101 is 13 in base 10.

Using the AND Operation example below. (NOTE: we see ‘0’ in a column, so the result of that column is 0)
1010
1101
— — -
1000

--

--

No responses yet