In my country, post-codes are also always 4 digits. But the first digit can be zero.
If you store "0700" as an integer, you can get a lot of problems:
- It may be read as an octal value
- If it is read correctly as a decimal value, it gets turned into "700"
- When you get the value "700", you must remember to add the zero
- I you don't add the zero, later on, how will you know if "700" is "0700", or someone mistyped "7100"?
Technically, our post codes is actually strings, even if it is always 4 digits.
You can store them as integers, to save space. But remember this is a simple DB-trick, and be careful about leading zeroes.
But what about for storing how many
files are in a torrent? Integer or
string?
That's clearly an integer.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…