|
You would also have to rewrite every table of physical constants. If you think the confusion between Imperial and Metric units is bad, just wait until "new metric" is added.
OTOH, if the Metro supermarket chain doesn't object, perhaps we could call it that...
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
--Winston Churchill
|
|
|
|
|
haha, At the company I work for, we have several systems that use delivery dates as primary keys/foreign keys. So we decided on using ints for this as well.
Today is the integer value 20171004
|
|
|
|
|
May be they were just trying to avoid a couple of mod operations.
I am not the one who knocks. I never knock.
In fact, I hate knocking.
|
|
|
|
|
If you hadn't mentioned SQL (obligatory Geek & Poke: Simply exåøaomed: SQL[^] I would have understood your worries.
Historically, databases (and Cobol ) primary belongs in the domain of administration, management and economy. You work with dollars and cents, maybe tenth of a cent as well, but that is exact. If you split a bill of $3.30 on three persons, $1.10 on each, and collect the three $3.30 for giving it to the taxi driver, he receives exactly $3.30. If you do it in the engineering style floating point numbers, the amount that the taxi driver rececives makes you associate to Pentium FDIV bug - Wikipedia[^]. Accountants are as mad at floating point inexactness as engineers are at the Intel bug!
So, at least since around 1960, developers of business software (as well as computer manufacturers making machines for executing that software) have been storing values in Binary-coded decimal[^] (BCD) format: Each binary digit takes up 4 bits. Since this gives 16 possibilities, the excess six are usually defined to represent numeric sign (+/-), currency symbol etc.
Note that conversion from ASCII to BCD digits is a simple masking (AND) operation, from BCD to ASCII setting a couple bits (OR). Most machines/libraries can handle BCD both eight bits to the digit (after simple ASCII masking) and four bits to the digit (sometimes called 'packed BCD'), for space saving.
Several CPU architectures support arithmetic operations on BCD values - although some not fully: I was working with a machine that had hardware (well, actually it was microcoded) add, subtract, and multiply of BCD. Dynamic analysis of real-life Cobol applications showed that BCD division was almost never done. The cost of implementing BCD divide in hardware was too high to justify it, so the instruction code was defined, causing an "Unimplemented instruction code" interrupt, and an interrupt handler performed the operation in software. (Very slow, but noone ever complained about that since 'nobody' ever did BCD divide.)
If your CPU does not provide BCD instructions, but you want to offer a Cobol compiler to your customers, you must implement BCD in software, for two reasons: Numeric data types are defined by the number of decimal digits, and that is exact, not "at least". If you have defined a 6-digit decimal, attempting to store a value of one million shall cause an exception. Second: You shall have an exact representation of fractional values - adding five times 20 cents shall give exactly one dollar.
I would not be suprised if those values you have come across is internally stored as BCD, being converted to binary int only because you insisted on it, requesting an int format. It is like converting BCD digits to ASCII digits - it is for presentation, not for processing. If your programming language doesn't support BCD, that binary format is what makes presentation easiest. If you need to do heavy processing, you can write the conversion to linear seconds in a single line numeric expression.
|
|
|
|
|
I worked on a system where date was stored as
(year << 16) | (month << 8) | (day-of-month)
When looking at the raw data, we used hex.
07E10A05 (07E1-0A-05) would be today's date: 2017-10-05.
Sorted correctly in the indexes and was very easy to interpret for month and day.
I am sure that the implementer of the SQL field was trying to make it user friendly for display.
I guess it HAS to be interpreted based on the local system/DB time zone.
|
|
|
|
|
|
Santa is magic, that can't be the end of him.
|
|
|
|
|
Few more days before Christmas, this reminds me of your post.
|
|
|
|
|
I didn't know that they had Coke way back then.
|
|
|
|
|
Is a spokesman good at straightening bicycle rims?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Tread carefully, OG!
/ravi
|
|
|
|
|
He is getting some radial ideas in his old age.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
Let's be careful we don't puncture his ego.
/ravi
|
|
|
|
|
That shouldn't be a problem, he seems to axle at these things.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
Yes, I hear it's going around.
/ravi
|
|
|
|
|
Ravi Bhavnani wrote: Yes, I hear
Does it sound like a fender?
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
I guess wheel see.
... such stuff as dreams are made on
|
|
|
|
|
|
Retired, perhaps?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I think the wheels are coming off...
|
|
|
|
|
|
you're pedalling some proper nonsense today
Format Success.
Welcome to your new signa&*(gD@@@ @@@@@@*@x@@
|
|
|
|
|
Do you never tyre?
... such stuff as dreams are made on
|
|
|
|
|
Perhaps wheel air our opinions on this chain of puns you've been peddling.
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
No, but handy with a talk wrench.
|
|
|
|