Fully understanding netmasks needs a bit of background in Binary (base 2) and Hexadecimal (base 16), and converting these and normal Decimal (base 10) numbers.
We'll start with a very quick background on bases, for those who weren't listening at school :-)
When you learned maths in primary school, you probably learned it like this (if not, then just pretend, okay?):
| Thousands 1000 | Hundreds 100 | Tens 10 | Units 1 |
|---|---|---|---|
| 1 | 2 | 3 | 4 |
This represents the number 1,234, which, as you could tell me without batting an eyelid, is one thousand, two hundred and thirty four. See, I told you this isn't difficult!
This is Decimal, or base 10. At the far right, the unit is 1's. So we've got 4x1=4, in our example. Moving left, we multiply 1 by the base number... 1x10 = 10, so the next column is tens, giving us 3x10=30, for a grand total so far of 34. Moving left again, multiply by 10 to give 10x10=100, and we've got 2x100 = 200, grand total 234. Moving left for a final time, 100x10=1000, 1x1000=1000, so the grand total is 1,234. For bonus points, you might notice that by tradition, we split the digits up into threes, using either a comma (",") or a dot ("."), like this: 1,234,567, or 1.234.567, depending on locale. In binary, we group them into 8's, in hex, we tend to group them into pairs.
In Decimal, we know that "9 + 1 = 10", but what are we doing here? 9 (being one less than 10) is the biggest digit we can have in any column, so we reset that column to zero, and the next-biggest column gets a 1. So 9+1=10, 19+1=20, etc. I'm not saying this because I think you don't know it, but because it's so obvious we often don't actually think about how and why we do it.
In Binary, the base is 2, so the ceiling is 1. This means that our thousands / hundreds / tens / units table looks like this:
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|
| 0 | 0 | 1 | 1 | 1 | 0 | 1 | 1 |
This is 59 in base 2. Just like we did with Decimal, we'll multiply the heading by the number under that heading, and add up the total. In this case, it's nice and easy, because we've only got ones and zeros, so we just have to find the ones: 32+16+8+2+1 = 59.
By tradition, we split these binary digits ("bits") into chunks of 8, as in the table above, which listed 59 as 00111011, or 8 bits. 8 bits make one byte. A "full" byte (11111111) is 255 decimal, or (as we will see below), FF in hexadecimal. 1024 bytes are a Kilobyte (Kb), and 1024 Kb are a Megabyte (Mb). 1024 Mb are a Gigabyte (Gb), and so on. Similarly, 1024 bits are a Kilobit, etc.
| 4096 | 256 | 16 | 1 |
|---|---|---|---|
| 1 | A | E | 3 |
Like with Base 10 and Base 2, we multiply by 16 each time we go left. We can now have numbers 0-9 and letters A-F. So 1AE3 is (1*4096) + (10*256) + (14*16) + (3*1) = 6,883. Sometimes for ease-of-reading, 1AE3 is shown as 1A:E3.
| Base 2 | 1111 | 1110 | 1101 | 1100 | 1011 | 1010 | 1001 | 1000 | 0111 | 0110 | 0101 | 0100 | 0011 | 0010 | 0001 | 0000 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Base 10 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| Base 16 | F | E | D | C | B | A | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
If we notice that the in the Binary byte (8 bits) above, 16 marks the halfway point of the Byte, one Byte can be represented by 2 hex characters:
| 16 | 1 |
|---|---|
| 3 | B |
We know the drill by now... 16*3 = 48; 1*B = 11. 48+11 = 59.
As we said above, a "full" byte (11111111 in base 2) is FF in Hex, or 255 in Decimal. We tend to display Hex in bytes, so whereas the decimal number 1,234 in binary is "00000100 11010010", in Hex, that would be "04:D2". Notice the conventions here; we tend to divide decimal numbers into threes, with a comma or dot; in binary, we divide into eights, with a space, and in hex, generally into pairs, with a colon (though sometimes into fours, eg Microsoft license keys, or eights, eg Veritas license keys).
The addition of letters means that you can even spell out words; surprisingly, there aren't many words that can be spelled out using only the letters A-F. In no particular order, DE:AD:BE:EF, C0:FF:EE, C0:DE, FE:ED, F0:0D, FA:CE, and CA:FE:BA:BE are pretty much all you can do in English.
So, you were already fluent in base 10 (the "normal" way of counting), base 24 (the 24-hour clock), bases 28, 29, 30 and 31 (for the day of the month), base 60 (for minutes of the hour), and possibly others - 52 (week of the year). You now know base 2 and base 16, too.