Binary numbers can seem intimidating at first,

since they look so different from decimal numbers.

But, as far as the basics go the math behind counting,

adding, or subtracting binary numbers is exactly the same as with decimal numbers.

It's important to call out that there aren't different kinds of numbers.

Numbers are universal.

There are only different notations for how to reference them.

Humans most likely because most of us have ten fingers and ten toes decided

on using a system with 10 individual numerals used to represent all numbers.

The numerals zero, one,

two, three, four, five, six, seven, eight and nine can be combined in

ways to represent any whole number in existence.

Because there are 10 total numerals in use in a decimal system,

another way of referring to this is as base 10.

Because of the constraints of how logic gates work inside of a processor,

it's way easier for computers to think of things only in terms of zero and one.

This is also known as binary or base two.

You can represent all whole numbers in binary in the same way you can in decimal,

it just looks a little different.

When you count in decimal you move through all of the numerals upward until

you run out then you add a second column with a higher significance.

Let's start counting at zero until we get to nine.

Once we get to nine,

we basically just start over we add a one to

a new column then start over zero in the original column.

We repeat this process over and over in order to count all whole numbers.

Counting in binary is exactly the same,

it's just that you only have two numerals available.

You start with zero, which is the same as zero in decimal.

Then you increment once.

Now you have one, which is the same as one in

decimal since we've already run out of numerals to use.

It's time to add a new column.

So now we have the number one zero which is the same as two in decimal.

One one is three,

one zero zero is four,

one zero one is five,

one one zero is six, one one one is seven, etc.

It's the exact same thing we do with decimal,

just with fewer numerals at our disposal.

When working with various computing technologies,

you'll often run into the concept of bits or ones and zeros.

There's a pretty simple trick to figure out

how many decimal numbers can be represented by a certain number of bits.

If you have an eight bit number you can just perform the math two to the power of eight,

this gives you 256 which lets you know that

an eight bit number can represent 256 decimal numbers,

or put another way the numbers zero through 255.

A 4 bit number would be two to the power of four,

or 16 total numbers.

A 16 bit number would be two to the power of 16 or 65,536 numbers.

In order to tie this back to what you might already know,

this trick doesn't only work for binary,

it works for any number system,

it's just the base changes.

You might remember, that we can also refer to binary as base two and decimal as base 10.

All you need to do is swap out the base for what's being raised to the number of columns.

For example, let's take a base 10 number with two columns of digits.

This would translate to 10 to the power of two,

10 and the power two equals 100,

which is exactly how many numbers you can represent with two columns

of decimal digits or the numbers zero then 99.

Similarly,10 to the power three is 1,000 which is exactly how many numbers

you can represent with three columns of decimal digits or the numbers 0 through 999.

Not only is counting in different bases the same,

so as simple arithmetic like addition.

In fact, binary addition is even simpler than

any other base since you only have four possible scenarios.

Zero plus zero equals zero just like in decimal.

Zero plus one equals one,

and one plus zero equals one should also look familiar.

One plus one equals one zero looks a little different,

but should still make sense.

You carried digit to the next column once you reached 10 in doing decimal edition,

you carry a digit to the next column once you reach 2 when doing binary edition.

Addition is what's known as an operator and there are

many operators that computers use to make calculations.

Two of the most important operators are OR and AND.

In computer logic, a one represents true and a zero represents false.

The way the or operator works is you look at each digit,

and if either of them is true,

the result is true.

The basic equation is X or Y equals Z.

Which could be read as,

if either X or Y is true then Z is true, otherwise, it's false.

Therefore one or zero equals one,

but zero or zero equals zero.

The operator AND does what it sounds like it does,

it returns true if both values are true.

Therefore, one and one equals one,

but one and zero equals zero,

and zero and zero equals zero, and so on.

Now, you might be wondering why we've covered all of this.

No, it's not to confuse you.

It's all really to help explain subnet masks a bit more.

A subnet mask is a way for a computer to use and

operators to determine if an IP address exists on the same network.

This means that the host ID portion is also known,

since it will be anything left out.

Let's use the binary representation of our favorite IP address

9.100.100.100 and our favorite subnet mask 255.255.255.0.

Once you put one on top of the other and perform a binary and operator on each column,

you'll notice that the result is the network ID and

subnet ID portion of our IP address or 9.100.100.

The computer that just performed this operation can now compare the results with

its own network ID to determine if the address is on the same network or a different one.

I bet you never thought you'd have a favorite IP address or

subnet but that's what happens in the wonderful world of basic binary math.