It should be obvious that you cannot compress a phone number. Compression has to be reversible. If you could compress the number so that, for instance, you could store, say, a 40 bit value in 32 bits, then your compression would not be reversible. There are 232 distinct values that can be stored in a 32 bit value. If there are more than 232 distinct telephone numbers, then compression cannot possibly help.
Probably the most expedient solution, if you must store as an integer, is to store the number as a 64 bit integer, Int64
. Convert from string using StrToInt64
. The largest value that can be stored in a 64 bit integer is 9,223,372,036,854,775,807
.
You will clearly need to sanitise your string before you attempt to call StrToInt64
. You'll need to remove spaces, hyphens etc. And are you sure that you can store the number as an integer. For instance, I might write a UK telephone number as +44 151 876 2765
. What will you do with the +
?
So, whilst Int64
gives you more range, you might wish to consider whether or not the value would be better stored in a string.