ТОП просматриваемых книг сайта:
Networking All-in-One For Dummies. Doug Lowe
Читать онлайн.Название Networking All-in-One For Dummies
Год выпуска 0
isbn 9781119689058
Автор произведения Doug Lowe
Жанр Зарубежная компьютерная литература
Издательство John Wiley & Sons Limited
Table 3-1 also shows the common shorthand notation for various powers of two. The abbreviation K represents 210 (1,024). The M in MB stands for 220, or 1,024K, and the G in GB represents 230, which is 1,024MB. These shorthand notations don’t have anything to do with TCP/IP, but they’re commonly used for measuring computer disk and memory capacities, so I thought I’d throw them in at no charge because the table had extra room.
Doing the logic thing
One of the great things about binary is that it’s very efficient at handling special operations: namely, logical operations. Four basic logical operations exist although additional operations are derived from the basic four operations. Three of the operations — AND
, OR
, and XOR
— compare two binary digits (bits). The fourth (NOT
) works on just a single bit.
The following list summarizes the basic logical operations:
AND: Compares two binary values. If both values are 1, the result of the AND operation is 1. If one or both of the values are 0, the result is 0.
OR: Compares two binary values. If at least one value is 1, the result of the OR operation is 1. If both values are 0, the result is 0.
XOR: Compares two binary values. If one of them is 1, the result is 1. If both values are 0 or if both values are 1, the result is 0.
NOT: Doesn't compare two values but simply changes the value of a single binary value. If the original value is 1, NOT returns 0. If the original value is 0, NOT returns 1.
Table 3-2 summarizes how AND, OR, and XOR work.
TABLE 3-2 Logical Operations for Binary Values
First Value | Second Value | AND | OR | XOR |
---|---|---|---|---|
0 | 0 | 0 | 0 | 0 |
0 | 1 | 0 | 1 | 1 |
1 | 0 | 0 | 1 | 1 |
1 | 1 | 1 | 1 | 0 |
Logical operations are applied to binary numbers that have more than one binary digit by applying the operation one bit at a time. The easiest way to do this manually is to line the two binary numbers on top of one another and then write the result of the operation beneath each binary digit. The following example shows how you would calculate 10010100 AND 11011101:
10010100AND 11011101 10010100
As you can see, the result is 10010100.
Working with the binary Windows Calculator
The Calculator program that comes with all versions of Windows has a special Programmer mode that many users don’t know about. When you flip the Calculator into this mode, you can do instant binary and decimal conversions, which can occasionally come in handy when you’re working with IP addresses.
To launch the Calculator, press the Windows key, type Calculator into the search bar, and then press Enter. When the Calculator is open, you can switch to Programmer mode by clicking the menu icon in the upper-left corner of the Calculator and choosing Programmer. In Programmer mode, you can do calculations in decimal (base 10), hexadecimal (base 16), octal (base 8), or binary (base 2). Figure 3-1 shows the Programmer mode for the latest version of the Calculator (as