IPv4 to integer
An IPv4 address is genuinely a 32-bit integer; the dots are a display convention. Storing it as an integer makes range queries trivial — a subnet is a contiguous span of integers, so "is this address in this network" becomes a simple comparison rather than string parsing. It is why databases handling IP data almost always store the integer form.
An IPv4 address is four bytes packed into a 32-bit integer. 192.168.1.1 becomes 3232235777 — that is 192×2²⁴ + 168×2¹⁶ + 1×2⁸ + 1. The dots are presentation, not structure.
How to convert an IP to an integer
The integer form makes subnet arithmetic straightforward. A /24 network is 256 consecutive integers, so checking membership is a range comparison rather than mask manipulation on strings. It also sorts correctly, which dotted-quad strings emphatically do not — sorted as text, 10.0.0.9 comes after 10.0.0.10. Any system storing addresses for querying benefits from the integer.
Questions
3232235777.