Guide
How to convert IPv4 to decimal, binary, and hexadecimal
Convert the four octets of an IPv4 address to an unsigned 32-bit integer, hexadecimal, and binary with a verifiable example.
by Tools in a Tab · Published on · Reviewed on
Short answer
An IPv4 address is a 32-bit value displayed as four decimal octets. The address
192.168.1.10 can also be represented as an unsigned integer, eight
hexadecimal digits, or 32 binary bits without changing its value.
Complete example
IPv4: 192.168.1.10
integer: 3232235786
hexadecimal: C0A8010A
binary: 11000000 10101000 00000001 00001010
The IPv4 and number-base converter performs both directions with exact integer arithmetic.
Octets to integer
Each octet occupies one base-256 position:
192 × 256³ + 168 × 256² + 1 × 256 + 10
= 3232235786
An equivalent implementation uses shifts of 24, 16, 8, and 0 bits. The valid
unsigned IPv4 integer range is 0–4294967295.
Integer to IPv4
Split the value into four groups of eight bits from most significant to least
significant. Every group must be between 0 and 255. For example,
hexadecimal C0 A8 01 0A becomes 192.168.1.10.
Keep all four octets
Abbreviated and octal-looking forms have historically received different
interpretations across software. Use exactly four decimal octets and avoid
leading zeros: 192.168.001.010 is not the canonical form accepted by the
tool.
Representation does not define the subnet
Converting an IP to an integer does not calculate its network. You still need a prefix or mask to obtain the network, broadcast, and range. Supply that extra information to the IPv4 subnet calculator.
Primary source
RFC 791 defines the IPv4 address as a 32-bit field in the protocol header.