One address, many spellings
An IPv4 address is really one 32-bit number. The familiar form with dots, such as 192.168.1.1, is only a way of writing it that people find easier: the 32 bits are cut into four groups of 8, and each group is written as a decimal number from 0 to 255. The same 32 bits can also be written:
- in binary, as 32 ones and zeros:
11000000.10101000.00000001.00000001 - in hexadecimal, 8 hex digits:
0xC0A80101 - as one whole number:
3232235777 - in octal, base 8.
The converter accepts the dotted form, the whole number or the hex form, and shows all of them.
How the conversion is done
Dotted to whole number. Multiply each part by its place value and add:
192 × 16,777,216 + 168 × 65,536 + 1 × 256 + 1 = 3,232,235,777
The place values are 256 cubed, 256 squared, 256 and 1, because each part is one base-256 digit.
Whole number to dotted. Divide by 256 again and again, keeping the remainders: they are the four parts from right to left.
Dotted to binary. Convert each part to 8 bits. For 192: 128 + 64 = 192, so the bits for 128 and 64 are 1 and the rest 0: 11000000. For 168: 128 + 32 + 8, giving 10101000.
Binary to hex. Each group of 4 bits is one hex digit: 1100 is C, 0000 is 0, so 192 is C0.
A table for the eight bit positions
| Bit position | 1st | 2nd | 3rd | 4th | 5th | 6th | 7th | 8th |
|---|---|---|---|---|---|---|---|---|
| Worth | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
To convert a number from 0 to 255 by hand, walk along the row: if the worth fits into what is left, write 1 and subtract it, otherwise write 0.
Where the other forms turn up
- Binary is how subnet masks are understood, and what networking exams ask for.
- Whole numbers are how databases and programs often store addresses, since a number sorts and compares faster than text. Location data files list ranges as pairs of whole numbers.
- Hex appears in packet captures, logs and some router screens.
- IPv4-mapped IPv6 (
::ffff:192.168.1.1) is how a system that speaks IPv6 inside refers to an IPv4 address.
One curiosity: many browsers will open a site if you type its address as a single whole number. That trick is sometimes used to disguise links in scam messages, so treat a link made only of digits with suspicion.
What is the largest IPv4 address as a number?
255.255.255.255 is 4,294,967,295, which is 2 to the power 32, less 1.
Does the converter handle IPv6?
No. IPv6 addresses are 128 bits and are already written in hex. Use the IPv6 expand and shorten tool for those.
Why does my calculator give a negative number for some addresses?
Some programs store the 32 bits as a signed number, so addresses from 128.0.0.0 upward appear negative. Add 4,294,967,296 to get the unsigned value shown here.