4000. You are building a database of addresses. The question was raised as to whether zip codes should be stored as numbers or strings. Explain what the differences are, and what the advantages/disadvantages are for each.

 

 

If Stored as a number (assuming, e.g., the zip code 12345):

It can not be stored as a numeric byte (Max value = 255)

It can not be stored as a signed integer

          (Max positive value = 32767; The zip code 32768 not stored)

It can not be stored as an unsigned integer

        (Max value = 65536; The zip code 65537 not stored)

It can be stored as a signed long (Max pos. value = 2147483647)

        or Unsigned long (Max Value = 4294967296)

 

            Therefore it will take 32-bits to store it as an integer and can perform mathematical operations on it (do we ever really need to?). Operations are more complex than with ASCII characters.

 

         If Stored as an ASCII Character:

        

         It will require 5-bytes (1-byte more than if stored as an integer). On the other hand, operations (especially printing) will be much easier. Assuming there are 99999 Zip codes (there are not), that means that it would require 399,996 bytes (3,199,968 bits) to store them all as an integer. It would require 499,995 bytes (3,999,960 bits) to store them all as ASCII characters (20% more storage).