Network Number System Conversions: Binary, Decimal, Hexadecimal
Introduction to Number Systems in Networking* Physical Layer & Bits: At the physical layer of a network, data is converted into electrical or optical signals representing ones and zeros (bits), which are the fundamental units of information that travel across networks. All internal computer operations use binary.
Human vs. Computer Representation: While computers operate in binary, they often display information like IP addresses to humans in decimal (base 10) for easier readability and understanding.
Types of Network Addresses
MAC Addresses & IP Addresses: These are the primary types of addresses used in networking.
MAC addresses: 48 binary bits in length.
IPv6 addresses: 128 binary bits in length.
IPv4 addresses: Each segment, separated by a period, is a decimal number between and . Internally, each of these decimal numbers is represented by eight binary bits.
Need for Conversions: Binary strings for addresses (especially MAC and IPv6) are extremely long and difficult for humans to read and write. Therefore, conversion to other number systems like decimal or hexadecimal (base 16) is necessary for human accessibility.
Decimal (Base 10) Number System
Place Value & Powers of 10: In decimal, each digit's position represents a power of . Starting from the rightmost digit:
Rightmost digit: Base to the power of zero
Next digit to the left: Base to the power of one
Next digit: Base to the power of two and so on.
Example:
in the place:
in the place:
in the place:
Sum:
Binary (Base 2) Number System
Core Concept: Powers of 2: Similar to decimal, binary uses powers of its base, which is . Digits can only be or .
Rightmost bit:
Next bit:
Next bit:
Next bit:
And so on, for higher powers.
Bits and Bytes: An octet is a group of eight binary bits, commonly used to represent each segment of an IPv4 address (e.g., ).
Binary to Decimal Conversion
Method: For each bit, multiply the bit value or by its corresponding power of . Then, sum all the results.
Example: to Decimal
Sum:
Example: to Decimal
Sum:
Example: to Decimal
Sum:
Decimal to Binary Conversion (Cisco Method)
Method: This method typically aims for an 8-digit binary representation because IP addresses use octets. (You always start with on the right and increase powers to the left.)
List the powers of from down to (decimal equivalents: ).
Starting from the largest power of (), ask if it can be subtracted from the decimal number.
If YES: Place a in the binary position for that power of , subtract the power of from the decimal number, and use the remainder for the next step.
If NO: Place a in the binary position for that power of .
Continue this process until all powers of down to have been evaluated.
Example: to Binary
: Can subtract from ? Yes. Binary: . Remainder:
: Can subtract from ? No. Binary: . Remainder:
: Can subtract from ? Yes. Binary: . Remainder:
: Can subtract from ? No. Binary: . Remainder:
: Can subtract from ? Yes. Binary: . Remainder:
: Can subtract from ? No. Binary: . Remainder:
: Can subtract from ? No. Binary: . Remainder:
: Can subtract from ? No. Binary: . Remainder:
Result:
Example: to Binary
: No () (Remainder )
: Yes () (Remainder )
: No () (Remainder )
: No () (Remainder )
: Yes () (Remainder )
: Yes () (Remainder )
: Yes () (Remainder )
: No () (Remainder )
Result:
Example: to Binary
: Yes () (Remainder )
: Yes () (Remainder )
: Yes () (Remainder )
: Yes () (Remainder )
: No () (Remainder )
: No () (Remainder )
: Yes () (Remainder )
: No () (Remainder )
Result:
Hexadecimal (Base 16) Number System
Purpose: Hexadecimal is used to efficiently represent very long binary numbers found in MAC addresses (48 bits) and IPv6 addresses (128 bits). It minimizes the number of digits needed.
Hex Digits: Hex uses and letters to represent decimal values :
Hextet: In IPv6, each grouping between colons is called a