Skip to main content
replaced http://superuser.com/ with https://superuser.com/
Source Link

As Lightness Races in OrbitLightness Races in Orbit and others have pointed out,

The INET(3) man page describes inet_addr and inet_aton, the standard functions used for converting the "IPv4 numbers-and-dots notation into binary form". It says

...components of the dotted address can be specified in decimal, octal (with a leading 0), or hexadecimal, with a leading 0X).

So technically, NO, an IP address with leading zeros is not (always) the same as one without leading zeros. In your case however, 192.168.2.100 and 192.168.002.100 are identical, because 002 == 2.

Any user interface which requires each component to be exactly three characters in length, with incorrectly-required leading zeros is broken.

As Lightness Races in Orbit and others have pointed out,

The INET(3) man page describes inet_addr and inet_aton, the standard functions used for converting the "IPv4 numbers-and-dots notation into binary form". It says

...components of the dotted address can be specified in decimal, octal (with a leading 0), or hexadecimal, with a leading 0X).

So technically, NO, an IP address with leading zeros is not (always) the same as one without leading zeros. In your case however, 192.168.2.100 and 192.168.002.100 are identical, because 002 == 2.

Any user interface which requires each component to be exactly three characters in length, with incorrectly-required leading zeros is broken.

As Lightness Races in Orbit and others have pointed out,

The INET(3) man page describes inet_addr and inet_aton, the standard functions used for converting the "IPv4 numbers-and-dots notation into binary form". It says

...components of the dotted address can be specified in decimal, octal (with a leading 0), or hexadecimal, with a leading 0X).

So technically, NO, an IP address with leading zeros is not (always) the same as one without leading zeros. In your case however, 192.168.2.100 and 192.168.002.100 are identical, because 002 == 2.

Any user interface which requires each component to be exactly three characters in length, with incorrectly-required leading zeros is broken.

Source Link
Jonathon Reinhart
  • 3.4k
  • 12
  • 37
  • 56

As Lightness Races in Orbit and others have pointed out,

The INET(3) man page describes inet_addr and inet_aton, the standard functions used for converting the "IPv4 numbers-and-dots notation into binary form". It says

...components of the dotted address can be specified in decimal, octal (with a leading 0), or hexadecimal, with a leading 0X).

So technically, NO, an IP address with leading zeros is not (always) the same as one without leading zeros. In your case however, 192.168.2.100 and 192.168.002.100 are identical, because 002 == 2.

Any user interface which requires each component to be exactly three characters in length, with incorrectly-required leading zeros is broken.