At 18:06  -0400 2009/03/17, Raul Miller wrote:
>On Tue, Mar 17, 2009 at 5:23 PM, James C Field 
><[email protected]> wrote:
>>>  Isn't this why IBM supported Binary Coded Decimal? Floating Point 
>>>sux for money.
>
>Floating point works fine for money unless you represent values as fractions.
>
>In other words, scale things properly and you should be fine.
>
>Bad: 1.99 dollars
>Good: 199 cents
>
>That said, if you are representing money values in cents, you can run
>into problems if you deal with values exceeding 45 trillion dollars.
>With inflation, this might become a real problem before too long.
>
>On the other hand, if inflation gets that bad, losing a few pennies here
>and there should be a relatively minor worry.  It's not as if they would
>be worth much of anything under those circumstances.
>

Too true! One of the "attractions" of BCD was to pack two decimal 
digits into one byte to save bytes. That is largely ignored in many 
newer systems and they just use 8 bit characters 0-9. I agree that a 
multiplier (like the one I mentioned AT&T using - 10000*cents) is a 
good idea in dealing with money.

Even so, in one case of a database I reverse engineered, there were 
literal numbers where the last character was 0-9 or p-y indicating a 
negative sign. This seemed to me to be a throwback to wanting to 
conserve bytes, and I have only ever seen it in this one case. Has 
anyone reading this thread ever encountered negative integers 
indicated in this way??? i.e. 123t <=> _1234

- joey

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to