Understanding the IP address to integer converter — concept and principle
This converter shows the same IPv4 address in four forms: dotted-decimal (192.168.1.1), a single unsigned 32-bit integer, hexadecimal and binary. You can type either a dotted address or a plain integer. Developers use it when storing IPs compactly in databases, comparing ranges in code, reading packet captures and logs that print hex, or importing geolocation tables that list ranges as integers.
How it is calculated
For an address a.b.c.d, where each octet is 0–255:
- Integer = a × 2^24 + b × 2^16 + c × 2^8 + d = a × 16,777,216 + b × 65,536 + c × 256 + d.
- Hex: each octet becomes two hexadecimal digits, written as 0x followed by 8 digits.
- Binary: each octet becomes 8 bits, shown in four groups.
- Reverse: a = ⌊N ÷ 2^24⌋, b = ⌊N ÷ 2^16⌋ mod 256, c = ⌊N ÷ 2^8⌋ mod 256, d = N mod 256.
Valid integers run from 0 (0.0.0.0) to 4,294,967,295 (255.255.255.255).
The principle
An IPv4 address is really one 32-bit number; the dotted notation is just a readable way to write its four bytes in base 256. Each octet is one "digit" of that base-256 number, so its place value is 256 raised to its position, exactly like hundreds and tens in decimal. Because the integer preserves order, numerical comparison works: an address is inside a range when start ≤ N ≤ end.
Worked example
- Input: 192.168.1.1.
- 192 × 16,777,216 = 3,221,225,472.
- 168 × 65,536 = 11,010,048.
- 1 × 256 = 256, plus the last octet 1.
- Sum: 3,232,235,777.
- Hex: 192 = C0, 168 = A8, 1 = 01, 1 = 01, so 0xC0A80101.
- Binary: 11000000.10101000.00000001.00000001.
How to read the result
A larger integer means a "later" address. Subtracting two integers gives the number of addresses between them, and a CIDR block is a range whose start is a multiple of its size. Hex is handy because each pair of digits lines up with one octet.
Common mistakes
- Storing the value in a signed 32-bit field; addresses above 127.255.255.255 then appear negative.
- Reading leading zeros such as 010.0.0.1 as octal, which some older tools do.
- Mixing up network byte order (big-endian) with the little-endian order of some CPUs when reading raw memory.
Frequently asked questions
What is 192.168.1.1 as a number?
3,232,235,777, or 0xC0A80101 in hexadecimal.
Why store IP addresses as integers?
An integer takes 4 bytes instead of up to 15 characters and makes range queries fast and simple.
Is the integer form a valid address in a browser?
Many browsers and tools accept it, but support is inconsistent, so use dotted notation in configuration.
Sources: IETF RFC 791, Internet Protocol