From -4362969514010626415
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,fed4da4ddd62c919
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1995-01-04 13:13:04 PST
Newsgroups: comp.std.c++
Path: nntp.gmd.de!Germany.EU.net!howland.reston.ans.net!gatech!newsxfer.itd.umich.edu!zip.eecs.umich.edu!newshost.marcam.com!uunet!world!miket
From: miket@world.std.com (Michael Trachtman)
Subject: Re: Packed Decimal and C++
Message-ID: <D1uv51.Frr@world.std.com>
Organization: High Level Designs
X-Newsreader: TIN [version 1.2 PL2]
References: <ncmD1sxAA.9vD@netcom.com> <95010300005913.DLITE.crayton@delphi.com> <ncmD1tIDx.3IJ@netcom.com>
Date: Wed, 4 Jan 1995 00:39:01 GMT
Lines: 23

In an article, Nathan Myers (ncm@netcom.com) wrote:
: >>It is a common misconception that more accurate computation is possible
: >>in BCD than in binary.  In fact, the only advantage that I know of for
: >>BCD is that conversion to and from ASCII is quicker.  [Er, and that  
: >>the Pentium bug doesn't affect you :-)]

My problem is that I have to represent amounts ranging from

$ .0001 (100ths of a penny) through 100,000,000,000 (100 billion) dollars.
To do this in integer requires about 43 bits of accuracy.
I.e. the ratio of the smallest number to the largest is about 1000 ^ 4.x.
It takes about 10 bits for each power of a thousand. (2 ^ 10  ~= 1000).

Regular integers, even the 32 bit kind won't work. Double precision
floating point will, however there will be roundoff error.

For accounting purposes, we have to match things exactly to the
accounting system. Thus, we need either 64 bit integers
or BCD, or some other arbitrary precision representation,
that guarantees at least  16 digits or so of decimal accuracy. 

Michael T.



