4 ms·
But a 2 digit date should take less than 7 bits. Were they using systems that didn't use 8 bit bytes? Why wouldn't the dates work from, say 1900 to 2155?
by MichaelGG 9y ago
But a 2 digit date should take less than 7 bits. Were they using systems that didn't use 8 bit bytes? Why wouldn't the dates work from, say 1900 to 2155?
- alanbernstein 9y agoGood question! Nobody was writing 1900 + (year % 100), right?
- nandemo 9y agoSome people were. But it's worse than that. In the 90s a lot of code used 16-bit values, character strings. That is, it stored a char(2), parsed it as 2-digit number and then converted it to a date by adding 1900. So it was only really "saving space" when compared with storing a char(4).
- MichaelGG 9y agoBut if they wanted to save space why not store a 8 bit number? I imagine it must have something to do with punch card compat or some binary coded decimal nonsense. Still seems inefficient.
- nandemo 9y agoMaybe because they didn't know better? I was going to say "maybe they were bad programmers", but likely just "average" programmers. No punch cards or BCD, I'm talking about DOS/Windows systems.
- vizeroth 9y agoIf a system gives you two options for storing a date (using 2-digit or 4-digit years), how many dates do you need to store and use in calculations before you end up saving space by creating a new data type and all of the supporting operations to make the storage of the date itself more efficient? In recent years, it's more common to make this type of decision because something else is causing an issue, otherwise we rarely consider the space required for a date (and many languages no longer have a separate type for dates).
- PeterisP 9y agoFor example, some systems stored the year in a byte, and when printing out a report it printed "19" and that byte - so year 1999 would be followed by year 19100. Some systems, where storing numbers in columns of characters were common practice (COBOL idiomatic style?) stored the date as two digits (possibly BCD), so the possible range is 00-99 no matter how many bits are used.
- deleted 9y ago[deleted]
- wpietri 9y agoMy understanding is that the actual number of bits used would generally have been 4 bits per digit, as they were using Binary Coded Decimal [1]. So dropping the 19 would save you a byte per date. Sure, they could have used a custom encoding. But that increases maintenance cost and extra development work. All to solve a problem that nobody cared about at the time. [1] https://en.wikipedia.org/wiki/Binary-coded_decimal https://en.wikipedia.org/wiki/Binary-coded_decimal
- MichaelGG 9y agoJust seems wierd. A 2 byte day count would give a huge range and use 2 bytes for the full date Vs 3 bytes for a BCD yymmdd representation.
- zaxomi 9y agoThere are a lot of weird things... You are assuming 8 bits per byte, but a byte can be any number of bits. With two bytes of 7 bits each, the range is only about 40 years. Is is also impractical when the storing media is punch-cards, and the systems adder unit only counts in binary coded decimal.
- wpietri 9y agoBut then you need special code to decode that. Code that you have to write yourself or borrow and include in your program. Remember, no shared libraries. And it means extra CPU time you have to display a date. Whereas BCD has special hardware support. It means that data interchange is now much more complicated too. How do you get everybody to agree on the same 2-byte representation for dates? This is the 1960s, so you can't just email them. You have to have somebody type up a letter and mail it. Or if you want to get on the phone, a 3-minute international call will cost $12, which is about $100 in 2017 dollars. Plus then you can't look at a hex dump or a punch card or front panel lights and see the date, so now you've made debugging much harder.
- zaxomi 9y agoBack in the days it was probably 7 bits, but the word size is not that important. The problem still exists today with a modern 64 bit computer: Even if a system internally can store a timestamp with nanosecond precision since the beginning of the universe, all that precision is lost when communicating with another system if it must send the timestamp as a six character string formated as "yymmdd" in ASCII.
- chrismcb 9y agoA 2 digit date typically used two guys, one for each digit. Cobol and all