14 ms·
Phone numbers are not numbers. Zip codes are not numbers. Model numbers are not numbers. Characters are not numbers. Which part of this progression escapes you?
by db48x 5y ago
Phone numbers are not numbers. Zip codes are not numbers. Model numbers are not numbers. Characters are not numbers. Which part of this progression escapes you?
Seriously, if you can’t add, subtract, multiply, and divide them, then they aren‘t numbers and you shouldn’t use a numeric data type for them. This is CS 101 knowledge. How badly does MS run their engineering?
- fortran77 5y ago> How badly does MS run their engineering? Bad enough to be a 2.53 Trillion Dollar company.
- hulitu 5y agoJust look at Win 10 and at Teams for examples. The only engineering which counts at MS is the one which maximizes profits.
- Demiurge 5y agoAnd how is this different for everyone else in the free market economy?
- dijit 5y agoI had a weird kind of epiphany when I was watching the fireworks over Sydney last night. The harbour bridge has lights on it. For what financial benefit? The fireworks display itself, I can't understand where the financial benefit is and it costs millions of dollars. ($7 million as far as I'm aware) --- I think that you could make a financial motivation statement for making good software (it makes it less likely for people to switch, for example), but my broader point is: why does everything have to be financially motivated? Because, a lot of stuff that we enjoy doesn't seem to be primarily financial in nature.
- dylan604 5y ago>The harbour bridge has lights on it. >For what financial benefit? Same for the Opera House. Imagine all of those stock photos of Sydney. Now narrow those down to the nighttime shots of Sydney. Imagine those without lights on the bridge or opera house. For that matter, any of the lights on any of the buildings. What do you have left? A really boring photo. Nobody wants to visit a city with really boring photos. What's the financial benefit of that?
- Jon_Lowtek 5y agoDoes not compute. What's the financial benefit of selecting cities based on how well lit their photos are?
- selestify 5y agoBetter lit structures make photos of them look better. Tourists choose destinations to spend money at based on how good the photos of the destinations look.
- Jon_Lowtek 5y agothat doesn't answer my question, i was asking why the tourist selects like that. How does selecting based on how well lit photos are create a financial benefit for the tourist? ;-)
- ben-schaaf 5y agoIt's not for the benefit of the tourists at all, it's an advertisement to increase tourism for the benefit of local businesses.
- Jon_Lowtek 5y agoYet such adverts should not increase tourism because tourists must surely prefer to visit cities that offer benefits for tourists.
- mind-blight 5y agoIt doesn't have to be, but our economy is structured to name it one of the primary ways to justify something's existence, Ave basically the only way to make something sustainable. The incentive structures are built to make financial incentives take precedence with most things
- reaperducer 5y agoA lot of people and companies take pride in their work. Saying that people are only in it for a buck is a tired old cliche that is easily disproven through even casual observation.
- samstave 5y agoIsn't it lovely that Bill Gates' famous words are that vaccines are the best investment he has ever made?
- frays 5y agoThe only reason I can think of is YYYYMMDDHHMM represented as an unsigned long is 4 bytes, while the equivalent in characters would require 12 bytes. Is it possible that at Microsoft's scale this would actually make a significant difference?
- pintxo 5y agoIt probably did, 25 years ago
- throwuxiytayq 5y agoNot likely. Modern software developers laugh this kind of difference away, and will almost always default to taking a memory/storage space hit over other possible trade-offs (performance, correctness, convenience...)
- watermelon0 5y agoConsidering storage/memory requirements for modern desktop/mobile apps, I wouldn't mind if developers would occasionally think about optimizing them.
- selfhifive 5y agoApplication developers not system engineers. People who work on high performance servers will always look to reduce overhead as much as possible.
- 5y ago
- zitterbewegung 5y agoThe only reason I can think of is that storing a version as a number would allow you to check if your version is incompatible with another server or feature / extension. By using less than or greater than.
- frays 5y agoIf they were stored as characters you could still do a string comparison using greater than and less than signs and logic. "202201010001" > "202112122359" evaluates to True in Python, SQL and many other languages.
- oefnak 5y agoBut "1000"<"999" in Python.
- thomasfedb 5y agoBut the format and length for these numerical strings is fixed.
- jpambrun 5y agoThis is going to be a problem in about 8,000 years tho.
- laumars 5y agoString comparison works as long as you order your date time by significance and zero pad all values, which they were doing with their date stamp anyway. Plus if they weren’t then even numerical comparisons would fail eg 1012021 (Oct/1/2021) < 5102020 (May/10/2020) so you argument is moot.
- 6c696e7578 5y agoWouldn't it be done more like this though? "%04d%02d%02d" % (999,1,1)
- ilikehurdles 5y agoNot necessarily. 2.2 is greater than 2.12 but v2.2 is actually an early predecessors to v2.12
- tyingq 5y agoNot that it excuses the issue, but I suspect the motivation was numeric sorting to identify the newest. So it was sort of a number in that respect.
- LadyCailin 5y agoNot criticizing you, but no, it’s a string which happens to have a natural ordering. The fact that it happens to look like a number is irrelevant.
- boardwaalk 5y agoIt’s like nothing could have multiple useful forms. Which is of course not true. This is just a dumb bug.
- tyingq 5y agoThe idea wasn't justifying the choice, but rather trying to imagine what happened. Because they did want a way to sort and pop the highest numeric value, they made a bad choice.
- deleted 5y ago[deleted]
- tomjen3 5y agoBut they are. Zips here in Denmark are clustered progressively, so that if you have a package going to (say) 8600 and 8704 then it makes some sense to send those orders to the same distribution node, since they will be close together, but to do that you need to treat them as numbers. My grandparents first phone number was 13. Not because they got in super early and had the 13th phone number in the country, but because that was the 13th number for their exchange. When a bunch of exchanges were put together everybody got another number in front of theirs. Their phone number is much longer today, but it still ends in 13. I guess you could treat the phone numbers as strings, but I don't know if you can do that with the Danish zip numbers.
- pintxo 5y agoLots of phone numbers start with a zero, converting string to numbers will most likely change the phone number by removing the information of the leading zero. Doing this in js will store it as base 8. Neither will make anyone happy.
- bombcar 5y agoExcel loves replacing phone numbers with 12031041e8 or whatever when importing CSV. So useful.
- dylan604 5y agoThis is one of the most annoying things to me about Excel (of a long list). In pretty much every time MS applications feel they are smarter than me ends in MS application being wrong. It doesn't matter if the data is manually typed or pasted from else where, when Excel tries to auto-guess how to set the formatting of the cell is just horrid. Dates are shite when trying to be in the US and using UK formatted dates.
- hermitdev 5y agoWhat's even worse is if you inadvertently save the CSV with the auto format, the data will be lost, too. Excel is both a wonderful tool and the bane of my existence when dealing with financials.
- skrebbel 5y agoCaptain Hindsight strikes again!
- hiptobecubic 5y agoVersion numbers can of course be numbers, but the problem here is that they were constructing a number like a string from semantically meaningful constituent parts (and not testing thoroughly).
- raverbashing 5y agoAnd again, if there are no negative versions, they should have used an unsigned int, not an int.
- genewitch 5y agopushing the date that it breaks to the version released in 2043?
- deleted 5y ago[deleted]
- MikusR 5y agoBut you can add and subtract dates.
- Turbots 5y agoAdd March 5th to June 2nd...
- _dain_ 5y agoAugust 5th.
- db48x 5y agoYou can only add a Duration to a Timestamp; you cannot add two Timestamps.
- deleted 5y ago[deleted]
- adolph 5y agoThe map is not the territory. The efficacy of any computational operator on a specific representation does not impute the same for all instantiations since the semantic link between identity and representation may only exist in the mind of the programmer and not the computational device.
- ajross 5y agoIt's neither a phone number, zip code, nor model number. It's a version number. And version numbers don't multiply or divide, but they do compare. This kind of code has a decades-long history: #if BUILD_VERSION >= FIRST_VERSION_THAT_WORKS ... #endif And in fact if you look around, almost every large C or C++ project has a WHATEVER_VERSION token (c.f. LINUX_VERSION_CODE for the kernel) that packs the version into a comparable integer literal. The bug here is that they picked an encoding that was obviously going to overflow in a Y2.022K bug, not with the technique.
- cesarb 5y ago> [...] almost every large C or C++ project has a WHATEVER_VERSION token (c.f. LINUX_VERSION_CODE for the kernel) that packs the version into a comparable integer literal. The bug here is that they picked an encoding that was obviously going to overflow [...] Speaking of LINUX_VERSION_CODE, it had a similar problem recently. See the article at https://lwn.net/Articles/845120/ https://lwn.net/Articles/845120/ which was summarized in this year's LWN.net retrospective at https://lwn.net/SubscriberLink/879053/aaea44782e8c760d/ https://lwn.net/SubscriberLink/879053/aaea44782e8c760d/ as follows: "Sometimes the most obvious things can be the hardest to anticipate; consider, for example, the case of minor revision numbers for stable kernel releases. A single byte was set aside for those numbers, since nobody ever thought there would be more than 255 releases of a single stable series. But we live in a different world, with fast-arriving stable updates and kernels that are supported for several years. It should have been possible for us, and for the developers involved, to not only predict that those numbers would overflow, but to make a good guess as to exactly when that would happen. We were all caught by surprise anyway."
- ajross 5y agoSimilar, but with the important distinction that this problem was recognized months in advance and remedied with some care (or kludge, depending on your preferences), and didn't become a bug in production software. All computers work in finite representations. All values can overflow. Good engineering is about working within that world and not trying to Quixotically design its absence.
- Pxtl 5y agoWe need null-terminated binary-coded-decimals as a standard datatype for cases like this. "Numeric String".
- ananonymoususer 5y agoOkay, so if it's null-terminated, how does one represent a zero?
- tom_ 5y agoDecide that the null value is one of the invalid digits - e.g., %1111. 0 can remain %0000.
- edoceo 5y ago"0\x00"?
- Pxtl 5y agoF-terminated might work better (given 1-nybble-per-digit BCD), or do a Pascal-style length prefix. I was less fixated on the implementation detail than I am about the basic concept of: arbitrary length numeric strings with numeric semantics and string-like storage and length characteristics.
- NelsonMinar 5y agoSo.. are database IDs numbers? Because they sure are autoincrement integers in almost every DBMS. I always thought that was a mistake but it's practical.
- Quekid5 5y agoYes, but as soon as they leave the realm of the DB itself, they (should) become opaque identifiers.
- masklinn 5y ago> So.. are database IDs numbers? No. > Because they sure are autoincrement integers in almost every DBMS. The autoincrement occurs before it's a database ID. The generator for database ids is a sequence, that has no bearing on the semantics of the database ids.
- mind-blight 5y agoIt's becoming pretty standard to use UUIDs over integers now. That provides more architectural flexibility
- marcosdumay 5y agoThey are absolutely not numbers. As many people already commented, it's reasonable to encode things as numbers as long as you keep in mind there's an encoding operation with it's possible flaws.
- kenjackson 5y agoHonestly that seems like a cop out.
- Spivak 5y agoI mean strings are numbers if you want to be that reductive. The “on-disk” representation of the thing is independent of its real type and properties. So sure, store a date in an “integer” but if you try to treat it like one instead of a bitfield you’ve made an error and if your storage isn’t wide enough to hold all dates that’s gonna be a PITA later.
- petee 5y agoYou're right but thats not the issue here, the version is structured as a number but they failed to give it a type large enough to represent it; simply a signed/unsigned screwup.
- masklinn 5y agoThat's not a fix, barely an improvement, really just a shitty workaround: the exact same issue rear its head again in 2043. The actual fix is exactly what the original comment states: a version is not a number.
- petee 5y agoOh I agree its a bad long term solution, but assuming they had noticed and used the correct type, 2043 is likely well past the lifetime of the product and would have worked fine till then. Not great, but certainly passable.
- masklinn 5y ago> Oh I agree its a bad long term solution, but assuming they had noticed and used the correct type, 2043 is likely well past the lifetime of the product You expect Microsoft Exchange to stop being used some time in the next 20 years?
- petee 5y agoThat version yes, absolutely. I expect at some point Microsoft will have made enough updates that they will say X version is no longer supported, and it will stop working on its own. And its not like it's a product installed on some embedded device that will never get updates until then, Exchange will get security fixes for as long as it is exists and nobody will be running this version in 20 years. Even more likely, we'll have new protocols the current version doesn't support, so the bug will have been long fixed or noticed.
- masklinn 5y ago
- collegeburner 5y agoSometimes a performance reason? Number is usually smaller, faster, also better if stored in a database and more efficient if used as a primry key,
- ClumsyPilot 5y agoGotta free up space for those electron apps
- bob1029 5y agoI have found that any time you would refer to a thing as a "Code" or "Number", you are almost certainly talking about a string. Every property name in our codebase that contains one of these terms is a string type without exception.
- dannyw 5y agoIf it's not a float or integer, it's a string.
- deleted 5y ago[deleted]
- quesera 5y agoAnd if it's currency, it should be an integer not a float.
- bob1029 5y agoWe use decimals for all currency and rate properties. Integer is fine in many cases too.
- quesera 5y agoBe careful with floats: 20.40 == (20.39 + 0.01) => false ("decimal" can either be colloqually-equivalent to "float", or it can refer to a distinct data type which is supported by some languages and databases. A proper decimal type is currency-safe to use, if available.)
- yholio 5y agoThese are version numbers. It's perfectly fine to use numbers to express version numbers, a great majority of protocols reserve numeric fields for this. The problem here was basic overflow, they reached a version number exceeding the capacity of the numeric type.
- rbobby 5y agoYYMMDD + 4 digits of versions. At a glance, even a bit more than a glance, that seems fine for a long. And if 2020 worked and 2021 worked... why would 2022 break? Lol. I'd bet the conversation about this way back when it was being decided was "will 3 digits for daily version/build be enough" and the answer "go with 4, better safe than sorry".
- snicker7 5y agoTime is a number. At least, it makes sense to subtract them (I guess you can say that time is a one dimensional affine space).
- kzrdude 5y agojust like pointers, it makes sense to subtract them and add offsets but to straight up add them makes no sense.
- pjc50 5y agoTime is a number and a location. If you normalize everything to a reference time such as the UNIX epoch, you can usually do subtraction. Even then you may have got the times from a non-monotonic clock ...
- bsza 5y agoTime is a number, but a date is not. 211231 + 1 != 211232.
- karpierz 5y agoTo be specific, that representation of date does not implement integer addition. To be fair, neither do most "number" types (uint, int, float, etc). For uint, you actually have x + y = (x + y) mod MAX_UINT. For float, sometimes x + 1 = x. The issue is not that date is not a number, but that people poorly reason about common cases of date arithmetic. Similar stuff comes up for floats and ints but they're just easier to reason about.
- gkop 5y ago> For float, sometimes x + 1 = x Would you spell this out for us?
- eska 5y agoIf x is a huge number, then elimination can happen. Floating point numbers store a mantissa and an exponent, m^e. When you have a huge number the exponent will be large. So the mantissa can not express the tiny number anymore.
- pvillano 5y agoside note some numbers^* cannot be meaningfully multiplied or divided. For example, 3^rd place, 30° F, or 37.388N,-122.067S. Some numbers can only be added to by numbers of a different type. For example x°C + y°K, 3rd grader + year, absolute position + offset. Similarly, subtracting two of these numbers results in a different unit. e.g. position - position = offset it would be great if someone could comment the exact terminology for what I'm trying to describe. * Types/Units
- mind-blight 5y agoI'm not sure if it's what you're looking for, but algebraic days types are a fairly common way to encode different kinds of days that have the same shape. You may also be looking for fields: https://en.m.wikipedia.org/wiki/Field_(mathematics) https://en.m.wikipedia.org/wiki/Field_(mathematics). You could probably also describe the relation between different number types as linear operators over a vector space
- john-aj 5y agoIn statistics, one usually differentiates between - nominal scales (e.g. man/woman), - ordinal scales (elementary school/middle school/high school), - interval scales (degrees Celsius) and - ratio scales (human height, degrees Kelvin). Only ratio scales may be multiplied and divided. Interval scales may be subtracted and added. Ordinal scales may only be compared (less/greater/equal). Nominal scales may only be compared in terms of (in)equality. https://en.wikipedia.org/wiki/Level_of_measurement https://en.wikipedia.org/wiki/Level_of_measurement
- pvillano 5y agothank you! this is that I was looking for
- jongalloway2 5y agoF# has Units of Measure: https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/units-of-measure https://docs.microsoft.com/en-us/dotnet/fsharp/language-refe... There are libraries that implement this concept in other programming languages (C++, Java, C#, etc.)
- Kevin578 5y agoisnt working with integers generally faster than working with strings? that might be why some ppl store phone numbers and zip codes as int
- ben-schaaf 5y agoNot if the only thing you're doing with the number is converting it from/to a string...
- petee 5y agoAnd its very doubtful that is all Exchange is doing with it. Likely they have a large list of definitions to compare and track.
- reaperducer 5y agothat might be why some ppl store phone numbers and zip codes as int Anyone who stores ZIP Codes as an int should have his dev license revoked. You've just corrupted the data you store for a hundred million people in the northeast. I'm currently dealing with a situation where a system developed by an offshore team stored Social Security numbers as integers. They had no idea that an SSN can start with a zero, and didn't even do a basic web search to see what the possible range of values is before designing the database and application.
- Kevin578 5y agoyou can tell a 4 digit zip code has a leading zero that was removed though. you'll also get faster sql queries if you search for zip codes as int vs string
- reaperducer 5y agoyou can tell a 4 digit zip code has a leading zero that was removed though Only if you're 100% sure your date is completely clean. Only very rarely is this the case, especially with ZIP Codes because the data almost always traces back to human input. The initial query may be quicker, but then you have to compensate for the missing digits elsewhere, likely multiple times. You have to consider the expense to the whole system, not just to one query.
- ed25519FUUU 5y agoThis is so extremely common that it’s funny to me you scoff at it. Under the hood these systems will convert to some numerical format to compare which version is newer. You store it as a (proper) numerical format or you serialize it into one later, but at the end of the day it’s a number because that’s how you compare it.
- dheera 5y ago> How badly does MS run their engineering? I think the real problem is ... how many good engineers and engineering managers nowadays want to work at MS?
- 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.
- darau1 5y agoWe use exchange at work. Daily, I will utter some form of "Microsoft can't do anything right, man".
- deleted 5y ago[deleted]
- michaericalribo 5y agoWell, to put on my pedantic hat and indulge my inner math major, what you describe is algebra on top of objects—you’re talking about the math that applies to numbers, not the numbers themselves. Specifically you described groups and fields and rings…the symbols themselves are numbers, but they don’t recombine with each other in the same way as other numbers. You’re right that they shouldn’t be implemented a numeric data types. That said, dates do have properties of modular arithmetic, so in a strange sense they are very much numbers… :p
- dehrmann 5y agoYou should try PHP. You can multiply all sorts of things!
- dehrmann 5y agoI used to work on a customer API that accepted these fields as JSON. My first project was improving validation (I used JSON schema) while not breaking existing integrations. While it's true that those fields aren't numbers, I saw all those fields sent as numbers.
- rbanffy 5y ago> Seriously, if you can’t add, subtract, multiply, and divide them, then they aren‘t numbers Sadly, sometimes you can, regardless of whether you should.
- SAI_Peregrinus 5y agoI'd say if they don't form an ordered field, they shouldn't be called "numbers". The complex numbers really ought to be called an algebra, not numbers. They're the dimension-2 Cayley-Dickson algebra, after all!
- comboy 5y agoEverything ends up in your database as bytes. You can say everything is a number. It's just naming. Whether it's sane to do basic math operations on them is loosely correlated with whether user sees that number as an integer on his screen. Most bugs are stupid and should be obvious. They happen. You can look at your old code and say WTF, so judging decisions in somebody's else complex system without having any idea about requirements and constraints seems pointless.