IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Subtle
We had a field in the DB defined as decimal, with 0 decimal places. Ask me how long it took for someone to notice that.

No, on second thought don't ask me that.
--

Drew
New We have AS400 databases with dozen upon dozen of those. Our RPG programmers refused to use Integer.
bcnu,
Mikem

It's mourning in America again.
New Might make sense
I seem to recall mainframe and s34/36/38 bcd storage and compute optimizations at the os and cpu level. Since as/400 is the next step of the s/3x line, they might have been maintained. Also, bcd math is different from integer math when handling money operations (forget how, just was trained to implement differently), so that may be why.
New Sounds vaguely familiar...
Long ago I worked for a Domino's franchise that had about 20 stores. They had a small AS/400 running the back end stuff. For a few weeks I did data entry stuff for their stores - things like entering how many sacks of flour each store needed the next day.

Sacks (or whatever) were entered as reals (10.00 sacks). I didn't understand it at the time, but they must have had a reason for doing it that way.

I learned things on that job like the ingredients for a large cheese pizza cost something like $0.2347. Buying in bulk really cuts the cost!!

Cheers,
Scott.
New Why to do that for flour
You start the day with 4 sacks of flour that weigh 50 lb each. You use 27 pounds of flour. How many sacks do you have left?
--

Drew
New But they ordered integer quantities.
I would get a call at 11 PM - "This is store #23 - I need 6 flours (bags), 7 cheeses (bags), 5 peppers (bags), ..." It was all integers.

The dB would have a total of XXX.XX bags of flour in the warehouse that some nominal subtraction was done from, but that was integer items as well (though it was also a real in the dB).

Maybe they had to have the quantities as reals to do the division to get the average prices to 4-5 decimal places or something. I dunno. Nobody ever explained it to me. It just seemed funky to me and it seemed to invite data entry errors (I had to enter 10.00 for 10).

At least that's my fuzzy recollection. It was nearly 30 years ago now. (Sheesh!)

Cheers,
Scott.
New But can you explain this?
Decimal(5, 0) for surrogate key values in tables?
bcnu,
Mikem

It's mourning in America again.
New Nope. I never was a dB coder.
New It wouldn't have helped if you had been. ;0)
bcnu,
Mikem

It's mourning in America again.
New You *order* integer quantities, but stock on hand is fractional
Someone building the UI today would (obviously, I hope) not require entering the ".00" every time, but weren't greenscreen apps much more closely tied to the underlying data?
--

Drew
New My recollection is that it was a funky program.
I would often end up with totals that exceeded the listed stock in the warehouse. (Negative warehouse totals resulted.) It didn't seem to matter - I was told to ignore it. I gathered that whoever was in charge of ordering stuff for the warehouse had some different way of keeping track of what was needed and when (but it sorta made what I was doing kinda pointless as far as that goes).

¯\_(ツ)_/¯

Programs are weird sometimes. :-)

Cheers,
Scott.
New BCD and old mainfraimes.
I think you might've hit on it. I seem to recall that so-called "integer" fields in languages like COBOL were really BCD fields.

BCD math (especially when the processor does it) has the advantage that you can just add more bytes to support a larger value. This avoids integer overflow problems, or at least makes them intuitive, particularly for non-programmers. Add decimal support and you've also avoided the problem of using floats for currency.

(I had a serious discussion many many years ago about the error characteristics of radix-2 floating point numbers and why you didn't want to use them for currency. Turns out there's a radix-10 version of IEEE-754 which is intended for currency. But microcomputers of the time all used radix-2 and therefore programs like Excel did, too.)

Wade.
New Saving space?
It doesn't matter much anymore these days, but if the data model goes back a while and you have a good grasp on the range of values, then decimal(x, 0) may have resulted in lower storage space use vs. a plain integer type.

decimal is a packed format. Depending on the database engine, it can take up as little as 1 byte where an integer takes at least 2*. Space savings would increase as the range goes up as the space needed for a decimal goes up 1 byte at a time. Integer would be 2/4/8.

* Assuming standard SQL.
     Subtle - (drook) - (12)
         We have AS400 databases with dozen upon dozen of those. Our RPG programmers refused to use Integer. -NT - (mmoffitt) - (10)
             Might make sense - (crazy) - (9)
                 Sounds vaguely familiar... - (Another Scott) - (7)
                     Why to do that for flour - (drook) - (6)
                         But they ordered integer quantities. - (Another Scott) - (5)
                             But can you explain this? - (mmoffitt) - (2)
                                 Nope. I never was a dB coder. -NT - (Another Scott) - (1)
                                     It wouldn't have helped if you had been. ;0) -NT - (mmoffitt)
                             You *order* integer quantities, but stock on hand is fractional - (drook) - (1)
                                 My recollection is that it was a funky program. - (Another Scott)
                 BCD and old mainfraimes. - (static)
         Saving space? - (scoenye)

Reason! Won't you put your blue dress on?
95 ms