Networking All-in-One For Dummies. Doug Lowe

Чтение книги онлайн.

Читать онлайн книгу Networking All-in-One For Dummies - Doug Lowe страница 57

Networking All-in-One For Dummies - Doug Lowe

Скачать книгу

232 4,294,967,296 4GB

      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.

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

       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.

      In the middle left of the Calculator window, you can see the current value displayed by the Calculator in hexadecimal (HEX), decimal (DEC), octal (OCT), and binary (BIN). You can also tell which base the main display shows, because it’s highlighted with a bar. In Figure 3-1, the current mode is DEC, so the decimal value 100 is shown in large text in the upper-middle part of the display. You can switch the main display to hexadecimal, octal, or binary by clicking HEX, OCT, or BIN, respectively.

      You can also see the current value in all four bases. Thus, in the figure, you can see that decimal 100 is 64 in hexadecimal, 144 in octal, and 01100100 in binary.

      Here are a few other things to note about the Programmer mode of the Calculator:

       Although you can convert decimal values to binary values with the programmer Calculator, the Calculator can’t handle the dotted-decimal IP address format that’s described later in this chapter. To convert a dotted-decimal address to binary, just convert each octet separately. For example, to convert 172.65.48.120 to binary, first convert 172; then convert 65; then convert 48; and finally, convert 120.

       The Programmer Calculator has several features that are designed specifically for binary operations, such as AND, OR, XOR, and so on.

       The Programmer Calculator also has many other cool features for working with binary values. Spend some time exploring it when you have a few minutes!

Snapshot of the Windows Calculator in Programmer mode.

      FIGURE 3-1: The Windows Calculator in Programmer mode.

      An IP address is a number that uniquely identifies every host on an IP network. IP addresses operate at the network layer of the TCP/IP protocol stack, so they are independent of lower-level data link layer MAC addresses, such as Ethernet MAC addresses.

      Networks and hosts

Скачать книгу