4
2
I teach a class on a software product my company makes and I find that students frequently add leading zeros to a configuration page to have the software connect to our hardware. Leading zeros are problematic in our software, that's how and why this comes up.
I always explained that leading zeros were against "the standard" thinking that's what I had been taught. As I was submitting the bug report up the chain to my engineering department, I was unable to find an authoritative source for this (i.e. "The Standard"), but I did find some interesting and related information.
Are leading zeros bad because of convention, or do they go against the standard?
This was the closest I could find to a standard to not use leading zeros, but it's an expired draft of some kind:
Textual Representation of IPv4 and IPv6 Addresses
In the relevant section, it says:
3 Syntax and Semantics
3.1 IPv4 Dotted Octet Format
A 32-bit IPv4 address is divided into four octets. Each octet is
represented numerically in decimal, using the minimum possible number
of digits (leading zeroes are not used, except in the case of 0
itself). The four encoded octets are given most-significant first,
separated by period characters.
IPv4address = d8 "." d8 "." d8 "." d8
d8 = DIGIT ; 0-9
/ %x31-39 DIGIT ; 10-99
/ "1" 2DIGIT ; 100-199
/ "2" %x30-34 DIGIT ; 200-249
/ "25" %x30-35 ; 250-255
I also found the following articles discussing the phenomenon:
Ping and FTP Resolve IP Address with Leading Zero as Octal
Leading zeros in IP address can result in incorrect routing
Are IP addresses with and without leading zeroes the same?
Is there any documentation for omitting zeroes in dot-decimal notation of IPV4 addresses?
Thanks for the link edits. Normally I prefer to have the full text of the URL below the title, but I couldn't get that done, and then I couldn't have more than 2 links, so that really cleaned up the question. – YetAnotherRandomUser – 2015-06-17T16:29:24.953
In the end, it all comes down to the parser implementation, so most systems should like it fine, but some may not.... standards implementations are always like that. – Frank Thomas – 2015-06-17T16:45:30.467