Every day, I see search hits on my blog entitled “2B OR NOT 2B = FF“. The blog itself never mentions what the title means. It was just a slightly cryptic reference to programming, because what I was writing about was the mindset that correlates with programming skillz. Anywhere up the autistic spectrum, basically.

But, for those baffled non-programmers resorting to Internet search to explain the expression, here it is: **the answer**.

It’s binary arithmetic, using two operators “**OR**” and “**NOT**“. For “**OR**” you take two **b**inary dig**its**, bits, and if either is “1” (or both are), the answer is “1”. Only if both are “0” is the answer “0”. The “**NOT**” operator works on one bit at a time and converts it to its opposite, so “0” becomes “1” and “1” becomes “0”.

The term “2B” as a number implies hexadecimal notation, which uses 16 different digits rather than the 10 from normal arithmetic. “0” to “9” are the same, but then you have “A” to “F” for 10 to 15. The advantage of hexidecimal in computing is that you can easily convert directly to binary, since each of the 16 digits corresponds to one of the 16 possible patterns of 4 binary bits. “2” is equivalent to “0010”, and “B” is “1011”.

“2B”, then, is the eight-bit binary number 00101011.

“**NOT** 2B” changes each bit to its opposite: 11010100.

00101011 **OR** 11010100 is 11111111 because there is a “1” in every position in one or the other.

*(In fact that happens for any case of “number OR NOT number”. It’s obvious if you think about it.)*

Finally, then, the hexadecimal digit for “1111” is “F”. That means that 2B **OR** (**NOT** 2B) **=** FF.

Different computing languages have different notations. In C and its relations, you have to indicate hexadecimal by prefixing with “0x”, and the usual style is to use lower case for “a” to “f” (although upper case is allowed). The “NOT” operator is written “!” and “OR” is written “|”, so the expression would read “0x2b | !0x2b” and the answer is “0xff”.

### Like this:

Like Loading...

*Related*