Prothon vs. Python integers

Roy Smith roy at panix.com
Tue May 25 08:16:45 EDT 2004


danb_83 at yahoo.com (Dan Bishop) wrote:
> Or credit card numbers.  They're 16 digits long, and Microsoft Excel
> has this inconvenient feature of displaying them with 15 significant
> digits.

I'm not sure credit card numbers are really numbers.  I think of them 
more as strings.  The fact that they're made up only of digits is almost 
meaningless, since you don't generally do any arithmetic operations on 
them.  You record them someplace and spit them back when needed.  Even 
as database keys, you're more likely to hash them than to use their 
arithmetic value directly.

One common operation is to figure out which vendor owns a certain 
number, and you do that by looking at the first four digits.  Thinking 
of it as a string, you would do "substring (digitString, 0, 4)".  
Thinking of it as an integer, you would do "int (value / 1000000000)".  
Which would you do?

Another common example of digit strings which aren't really numeric 
values is a telephone number.  If I've counted properly, to call a 
number in London, England using my calling card, I need to dial 31 
digits (access number + 01 + country code + local number + auth code + 
PIN).  Sure, they're all digits, but I think any sane system would store 
that as a string, especially given that the only operation I ever want 
to do with the sub-parts is concatenate them in various ways.



More information about the Python-list mailing list