# Guide to Converting IP Addresses from Decimal 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 converting IP address from decimal to hex, 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.

## 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. For example, you can easily convert an IP address to binary to understand its underlying structure and format.

## 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. So sometimes converting IP addresses from decimal to hex makes sense. Learning these alternative number systems will empower you to work more effectively as a programmer, networking professional, or technologist.

## Related Articles

- All
- Easy Prey Podcast
- General Topics
- Home Computing
- IP Addresses
- Networking Basics: Learn How Networks Work
- Online Privacy
- Online Safety

### Protect Against Ransomware by Planning for Ransomware

Ransomware is a huge cybersecurity threat, and it’s only growing. It’s especially a risk for businesses, but…

[Read More]### PIA: Private Internet ACCESS

The Private Internet ACCESS VPN will deliver the security, performance, and online access most users want. Behind...

[Read More]### Everything You Need to Know about Spyware, the Malware that Stalks Your Online Activity

Spyware may sound like something James Bond or another secret agent might use in the latest spy…

[Read More]### Easy, Non-Technical Ways to Protect Your Privacy Online (And Why You Need To)

We all use technology at some point in our lives. Sometimes that technology is as simple as…

[Read More]### ExpressVPN

ExpressVPN has long had the reputation of being one of the best, fastest, and most secure VPNs…

[Read More]### Gmail Confidential Mode: Useful but Imperfect for Email Privacy

Email is a tool that most of us use every day – sometimes all day. And while…

[Read More]