Here’s a thing surprisingly few programmers seem to get: there’s a difference between a number and a string that happens to only contain digits. If it doesn’t make sense to add two such things together then it’s the latter and not the former; think ID numbers, ISBNs, credit card numbers, and the like

@rlamacraft Aren't some of those numbers involved in some mathematical formula to ensure that those are valid numbers? Wouldn't those need to be a number then?

@trinsec That’s a fair point, maybe some of them are best described as a list of digits, but they’re certainly not natural numbers


I think the real distinction here is not "what are they" but rather "what do you tream them as".. All of those are numbers, and they are natural numbers. But as you point out since we never have to use them like a number (do any math on them) we can and should treat them as a string or arbitrary object.

To @trinsec 's point if you need to perform the math on them that is used to verify them in some way then they are treated like a number, no different from any other "natural number" but if we arent or wont be performing that math then we done.

The same is true for other properties.. if all we care about is equality and wont ever need to display the data then it is treated as an arbitrary object, no need to even really treat it as a string at that point. Strings are for renderable text, so only time you ever need to think of them as a string is if you intend to display it, just as the only time you need to think of them as a number is if you need to do math on them.

@trinsec @rlamacraft Most of these calculations use the ID as list of digits.
Often, they are generated as a number ( last one used + 1 ), and then a digit is added for the validity check.
Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves. A STEM-oriented instance.

An inclusive free speech instance.
All cultures and opinions welcome.
Explicit hate speech and harassment strictly forbidden.
We federate with all servers: we don't block any servers.