From -5168903456140954339
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,fed4da4ddd62c919
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1995-01-02 18:13:07 PST
Newsgroups: comp.std.c++
Path: nntp.gmd.de!Germany.EU.net!howland.reston.ans.net!ix.netcom.com!netcom.com!ncm
From: ncm@netcom.com (Nathan Myers)
Subject: Re: Packed Decimal and C++
Message-ID: <ncmD1sxAA.9vD@netcom.com>
Summary: exact-precision arithmetic package already available
Keywords: bcd money accuracy commercial
Organization: NETCOM On-line Communication Services (408 261-4700 guest)
References: <D1pB3B.Eyo@world.std.com>
Date: Mon, 2 Jan 1995 23:30:09 GMT
Lines: 36

In article <D1pB3B.Eyo@world.std.com>,
Michael Trachtman <miket@world.std.com> wrote:
>Will C++ ever have a standard set of types and operations for
>packed decimal based numbers ? 

The great thing about C++ is that you can write your own type 
-- or buy it from anybody who did.  [plug alert:] Rogue Wave Software 
(e.g.) offers such a library, called "Money.h++".

>Such a set of types would be useful for writing base 10, arbitrary
>precision, penny accuracy (i.e. no floating point round off errors)
>programs.

> ... However, a compiler vendor would be free
>to implement it internally, and generate high quality assembler
>on those machines that have hardware support for Packed decimal.

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 :-)]

Any package can be optimized for any given compiler (given asm {} 
support) without imposing a requirement for such support on every 
implementation.  In environments where such a package is popular 
one could ask one's library vendor to do it, without any help from 
an overburdened standards committees.

Generally, IMHO we are better served by asking the committee for better
support for library writing, than for features that can already be 
implemented (more or less well) in a library.  That way you will see
more and better libraries to choose among, including those you forgot
to have standardized.

Nathan Myers (speaking personally, but employed by...)
Rogue Wave Software


