How to convert a Zip9 or Zip4 to a Zip5 if you're missing leading zeros
08 February 2014
For when Excel turns 057531234
into 57531234.0
(drops leading zeros and treats it like a number) and you just want 05753
.
Here’s the problem in the form of an acceptance test:
Here’s a quick Ruby method to solve it:
Works:
You could take the warning out if you want - technically 501..99950
is full range of zip codes.