Boost logo

Boost :

From: Ken shaw (ken_at_[hidden])
Date: 2001-05-09 12:45:40

This is a good idea. I also work with many novice programmers who struggle
with not using floating point for currency. The class should support all the
usual arithmetic operations along with some of the more common accounting

Ken Shaw
Programming Manager
Computer Innovations
Chicago IL

----- Original Message -----
From: "Bill Seymour" <bsey_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Wednesday, May 09, 2001 12:01 PM
Subject: [boost] Fixed-Point Decimal Type

> When J16 and WG21 begin working on specific proposals for the
> evolution of C++, I intend to suggest a fixed-point decimal type.
> The main reason is that many novices want to use floating-point
> types to store monetary values; and they're suprised when the
> pennies (or other fractional values) don't add up. In the
> traditional "business data processing" environment in which
> I work, this is often what Bjarne calls an "embarrassment."
> If there's interest, I'd like to do a reference implementation
> under the auspices of Boost. The requirements for the type
> would be:
> - A template class with the template parameter being the number
> of digits to the right of the decimal point.
> - Represent at least 18 decimal digits exactly. (The 18 comes
> from prior art on IBM mainframes, and also turns out to be
> convenient if the internal representation is a 64-bit int.)
> - Support all operations that can be done on ints except implicit
> conversions and non-decimal I/O.
> - All operations are exact if there is no overflow and if no
> rounding is required. Overflow is undefined behavior.
> Rounding is done the way accountants do it: round to nearest
> with 1/2-LSB always rounded "up." (I think "up" means "away
> from zero." I've asked an accountant friend via e-mail but
> haven't yet gotten an answer.)
> - Construction from const char* for faking decimal constants.
> - Explicit conversion to/from double.
> Are there more requirements that I haven't thought of?
> All comments and flames are welcome.
> --Bill Seymour
> To unsubscribe, send email to: <mailto:boost-unsubscribe_at_[hidden]>
> Your use of Yahoo! Groups is subject to

Boost list run by bdawes at, gregod at, cpdaniel at, john at