Skip to content

Understanding IP Addressing and How to Convert IP Addresses to Hex

IP Addressing and Converting IP Addresses to Hex

If you’re unfamiliar with number systems like binary and hexadecimal, stay tuned. Understanding how these systems work is key to grasping many technical concepts. 

And if you are curious about how to convert IP addresses, this article provides a beginner-friendly explanation of decimal, binary, and hexadecimal numerals.

Before you can start converting IP addresses, it’s important to understand that An IP address can be represented in formats like dotted decimal, binary, octal, or hexadecimal. 

Although each representation conveys the same meaning, dotted decimal notation is typically used for IPv4, while IPv6 often employs hexadecimal (hex) notation.

The Decimal Number System

The number system most of us use in everyday life is called decimal, or base 10. It uses ten distinct digits – 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. After 9, we cycle back to 0 and start the next “place value” in tens.

Decimal is a positional system where the value of each digit depends on its place or position. For example, in the number 2,345:

2 is in the thousands place, so its value is 2 x 1000 = 2000

3 is in the hundreds place, so its value is 3 x 100 = 300

4 is in the tens place, so its value is 4 x 10 = 40

5 is in the ones place, so its value is 5 x 1 = 5

Add the values of all the places and you get 2,345. As you move left, each place increases by a power of 10. This pattern lets us represent large numbers compactly.

What is a binary number?

Understanding Binary

Computers operate using binary, or base 2, numbering. Binary only uses two digits – 0 and 1. So how does binary represent large numbers with just 0s and 1s?

Binary is also positional, but each place value doubles rather than going up by powers of 10. Starting from the right, the places represent 1, 2, 4, 8, 16, and so on, doubling each time:

1’s place: 20 = 1

2’s place: 21 = 2

4’s place: 22 = 4

8’s place: 23 = 8

For example, the binary number 101 is:

1 x 22 (4) = 4

0 x 21 (2) = 0

1 x 20 (1) = 1

Add the place values: 4 + 0 + 1 = 5. So binary 101 represents decimal 5. Binary allows complex data to be encoded in strings of 0s and 1s.

Introducing Hexadecimal

Hexadecimal, or hex, is base 16. It uses 16 distinct digits, 0 to 9 plus A, B, C, D, E, and F representing decimal values 10 to 15. The place values in hex are powers of 16:

1’s place: 160 = 1

16’s place: 161 = 16

256’s place: 162 = 256

For example, hex 2FE breaks down as:

2 x 162 (256) = 512

F x 161 (16) = 240

E x 160 (1) = 14

Adding the place values gives 512 + 240 + 14 = 766. So hex 2FE = decimal 766.

Hex is useful because it can compactly represent binary data. Each hex digit encodes 4 binary bits, so a byte (8 bits) needs just 2 hex digits. Hex is commonly used in computer systems for addresses, encoding data, and machine code.

Converting Between Number Systems

Being able to convert between decimal, binary, and hex is crucial for understanding IP addresses, subnet masks, machine instructions, and other technical concepts. Here are some tips:

  • Decimal to Binary: Repeatedly divide by 2, recording remainders from bottom to top. Remainders give the binary digits.
  • Binary to Decimal: Add place values of bits that are “on” (1).
  • Hex to Binary: Convert each hex digit to 4-bit binary.
  • Binary to Hex: Break into 4-bit groups and convert each to hex.
  • Decimal to Hex: Convert to binary first, then binary to hex.

Online converters and programming languages like Python also have built-in functions to convert between number systems. With some practice, you’ll get comfortable transforming decimal, binary, and hex representations.

Understanding Number Systems in Networking and Computing

 IP addresses are a prime example of how different number systems come into play in networking:

  • The familiar dotted decimal notation (like 192.168.1.25) represents IPv4 addresses in a human-readable format. But networked devices actually process and forward IPv4 packets using 32-bit binary representations.
  • IPv6 addresses utilize 128-bit addressing, making their binary forms tedious and difficult to manage. Hexadecimal provides more compact and manageable representations for IPv6 addresses, like 2345:ABCD:0FED:CBA9.
  • While IP addresses can theoretically use decimal, binary, octal or hexadecimal, convention is to use decimal points for IPv4 and hex for IPv6. This matches the common numeric formats used by humans and machines for each IP version.

In networking and computer science, being fluent in binary and hex is essential. Here are some examples:

IP addresses like 192.168.1.25 are stored as binary values in 32 bits.

Media access control (MAC) addresses use 48-bit hex digits like 5A:23:10:AB:C4:E9.

Encoding and decoding data uses binary and hex representations.

Assembly language and machine code rely heavily on hex opcodes and binary instructions.

While decimal makes sense intuitively, your programs and network gear crunch the 0s and 1s of binary code under the hood. Hex provides a convenient shorthand for working with binary. Learning these alternative number systems will empower you to work more effectively as a programmer, networking professional, or technologist.

Related Articles

All
  • All
  • Easy Prey Podcast
  • General Topics
  • Home Computing
  • IP Addresses
  • Networking Basics: Learn How Networks Work
  • Online Privacy
  • Online Safety
  • Uncategorized
Stuart Wells talks about identity verification, synthetic IDs, and more.

Identity Verification Solutions for a World of Synthetic IDs

Synthetic identity fraud takes pieces of information from real people and manipulates them so a criminal can…

[Read More]
AI ethics rules should change and adapt as technology gets better and new ethical issues come up.

OpenAI and the Future of Ethical GPT Guidelines

Recently, you’ve probably heard OpenAI mentioned frequently on news channels and in high profile publications. The advent…

[Read More]
Learn why backup is important and how to do it easily.

Why Backup is Important: It Protects You and Your Data

Our devices – phones, tablets, and computers – are important to us. But when you think about…

[Read More]
How to choose a VPN for your Apple TV

Best VPNs for AppleTV You Can Purchase

Rumors are swirling that Apple might be releasing a long-awaited update to their AppleTV box unit in…

[Read More]
VPN being used on your personal laptop

How to Download a Free VPN Hotspot Shield

With data breaches and privacy violations running rampant online, protecting your security is more crucial than ever….

[Read More]
Michelle Couch-Friedman talks about the Vantage Travel bankruptcy and how you can avoid being the victim of a bankrupt company.

Protect Yourself From Financial Loss When Booking Travel

Imagine you’re booking a vacation. It’s a big trip, like a cruise or a tour. You’ve been…

[Read More]