Is a credit/debit card number numeric or an integer?
Credit card numbers are not strictly numbers. They are strings, but the numbers which make up the long 16 digit number can be exploded in order to validate the number by using the checksum of the number.
You aren't going to be doing any multiplication or division on the CC number, so it should be a string in my opinion.
Quick Prefix, Length, and Check Digit Criteria
CARD TYPE | Prefix | Length | Check digit algorithm
-----------------------------------------------------------------
MASTERCARD | 51-55 | 16 | mod 10
VISA | 4 | 13, 16 | mod 10
AMEX | 34/37 | 15 | mod 10
Discover | 6011 | 16 | mod 10
enRoute | 2014/2149 | 15 | any
JCB | 3 | 16 | mod 10
JCB | 2131/1800 | 15 | mod 10
Don't use an integer for this.
Depending on the size of your integers (language/machine dependent), they may be too large to store as integers.
The use of credit card numbers is also not as integers, as there's no reason for doing arithmetic with them.
You should generally regard them as arrays of decimal digits, which might most easily be stored as strings, but might merit an actual array, again depending on your programming language.
They also contain encoded banking authority information as described in the wikipedia article on Bank Card Numbers, and are a special case of ISO/IEC 7812 numbers, which in fact can start with zero (though I don't think any credit cards do). If you need this information, a CC number might actually merit it's own data type, and likely some banks implement one.
Better to use an array of single-digit ints
. Often the individual digits are used in some type of checksum to validate the credit card number. It would also take care of the case that a CC# actually starts with 0.
For example,
int[] cc = { 4, 3, 2, 1 }
bool Validate(int[] cc)
{
return ((cc[0] + 2*cc[1] + 6*cc[2]) % 5) == 0;
}
Something like that, although the equations they use are more complex. This would be a lot harder (i.e. would require division and truncation) with just
int cc = 4321;
Edit:
Keep in mind also, that each digit in a credit card number means something. For example, the 3rd and 4th digits might represent the state in which the card was made, and the 5th digit might be an index to the particular bank that issued the card, for example.