True enough for database or dictionary storage, but a lot of times things get implemented in arrays where you still wind up with two copies of the same uint32.
Comment on GoOn
dannym@lemmy.escapebigtech.info 1 year agoDefinitely, tho if you store it as a u32 that is fixed magically. Because 1.2.3.4 and 1.02.003.04 both map to the same number.
What I mean by storing it as a u32 is to convert it to a number, similar to how the IP gets sent over the wire, so for v4:
octet[3] | octet[2] << 8 | octet[1] << 16 | octet[0] << 24
or in more human terms:
(fourth octet) + (first octet * 256^3) + (second octet * 256^2) + (third octet * 256)
Emma_Gold_Man@lemmy.dbzer0.com 1 year ago
p1mrx@sh.itjust.works 1 year ago
But 10.20.30.40 and 010.020.030.040 map to different numbers. It’s often best to reject IPv4 addresses with leading zeroes to avoid the decimal vs. octal ambiguity.