7 ms·
> Seriously, if you can’t add, subtract, multiply, and divide them, then they aren‘t numbers You’ve missed a ton of other scenarios here, the relevant one bein
by djrogers 5y ago
> Seriously, if you can’t add, subtract, multiply, and divide them, then they aren‘t numbers
You’ve missed a ton of other scenarios here, the relevant one being a compare operation with a < or > output. These are version numbers. Version numbers the way they’re used here increment, they are not random strings, which is what you’re effectively suggesting.
If the version numbers here were represented as strings they’d need to be converted to a number at some point to compare them, and you’d probably run into the same problem you have here.
Of course I’m sure you’d have the perfect, completely applicable, and universally accepted solution then as well…
- wolf550e 5y agoISO8601 strings are sortable and are not numbers.
- 88913527 5y agoCharacter sorting isn't a natural law. The fact that "A" comes before "Z" is historical; it's 'always been done that way'-- at least since the Phoenicians. https://en.wikipedia.org/wiki/History_of_the_alphabet#Descendants_of_the_Aramaic_abjad https://en.wikipedia.org/wiki/History_of_the_alphabet#Descen...
- tuwtuwtuwtuw 5y agoNo they aren't. 10000 can be a valid year according to ISO8601, but sorted as a string it would come before year 2000, which would obviously be incorrect. Here's from the ISO: > 3.5 Expansion By mutual agreement of the partners in information interchange, it is permitted to expand the component identifying the calendar year, which is otherwise limited to four digits. This enables reference to dates and times in calendar years outside the range supported by complete representations, i.e. before the start of the year [0000] or after the end of the year [9999].
- otterley 5y agoSounds like a problem we don’t have to worry about for another 8,000 years or so.
- SAI_Peregrinus 5y agoWhich comes first, "2021-W52-6T15:10.4" or "20220101T151115.1-05"? Lexicographic sort between those two ISO-8601 date/time strings will get it wrong. Did you mistake ISO-8601 for RFC-3339? Even there lexicographic sorting isn't guaranteed, since you can have a pure date or a pure time or a date-time combined, and there's a choice between "T" and " " to separate dates from times in a date-time but it's much more likely to work than with ISO-8601.
- lolinder 5y agoComparing strings is trivial, and would work out of the box with the format that they're using (YYMMDD###).
- Jenk 5y ago> Version numbers They still aren't compatible with number types. They are groupings of numbers at best. 2.9 is an earlier (not less than) version than 2.10. 3.1.6 isn't a (strict) numerical format. 5.4.11-beta1 has non-numerics.
- tuwtuwtuwtuw 5y agoIf you define your version numbers to be numbers, then your version numbers will be numbers. I really don't get the confusion over this.
- Jenk 5y agoThe assumptions/traits/expectations that come with numbers (and most importantly, that are embedded into the number _types_) may not be consistent with _version number_ types.
- tuwtuwtuwtuw 5y ago
- Jenk 5y agoI think you need to read the thread again. The point (there is just one) I've made in both replies has been very clear and direct.
- tuwtuwtuwtuw 5y ago
- Jenk 5y ago
- Spivak 5y agoI mean if your standard for “numbers” is “can be mapped 1-1 to integers” then everything is a number. The operations you actually do to numbers have to have meaning in the space you’re defining. Does “1.2.0” + “2.3.0” make sense in your world? And if you’re like what about ordering and comparisons, then sure, you have a partially ordered set.
- akersten 5y ago> the relevant one being a compare operation with a < or > In Math we call that subtraction!
- pigbearpig 5y agoThese should have been strings, end of story. You can sort a string. Amazing to see storing a non-number as as number being defended. Truly CS101.
- petee 5y agoI'm curious which languages you learned in CS101 (actual question, not snark) Every non-number, as you put it, is just a number to a computer. Comparing binary is faster than sorting strings, and it makes zero sense to waste memory simply so a human could potentially read it.
- jraph 5y agoBut versions are for human beings. Otherwise, a timestamp, a date, a commit hash or an increment would do.
- petee 5y agoThat's not true, they can be for either humans, computers, or both. Software still has to understand and do something with that version number, even if it came from a human. And if it has to store, sort, or process that number a lot, it will still be faster to store and compare binary than a string. For comparison, I think some here would be shocked to learn their IPv4 address is stored as an unsigned 32-bit integer. Its not a number, and definitely not faster to use as a string.
- DSMan195276 5y agoYou can certainly sort a string, but I think there are valid reasons to avoid it if possible. What they shouldn't be doing is trying to shove it into a single 32-bit integer - if they parsed it into separate integers for each of the individual parts (like a simple date representation would do) then the issue would go away. Whether it's worth that extra work to avoid the string comparison is debatable, but if they go on to mask out parts of the version number and look at them individually (Ex. Only the year, or only the revision number) than it would probably be worth it to just do all the parsing upfront and avoid any messing with strings after that.
- WoahNoun 5y agoPosets aren't numbers either.
- mr_toad 5y agohttps://en.wikipedia.org/wiki/Ordinal_number https://en.wikipedia.org/wiki/Ordinal_number