Boost logo

Boost :

From: Beman Dawes (bdawes_at_[hidden])
Date: 2001-05-09 14:06:38

At 01:01 PM 5/9/2001, Bill Seymour wrote:

>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.

I think a fixed-point type would be useful, and Boost would be a good place
to develop existing practice in preparation for a standard library

>Are there more requirements that I haven't thought of?

Do make sure that it is easy to do the formatted output needed for business
use, including internationalization. Options for fills, floating currency
indicator, significance starter, various ways to indicate negative
(included parentheses), separators, etc. All that stuff accountants care
about. If it turns out the standard library's iostream and locale
mechanisms are strong enough, then just document that. But otherwise some
such facility is bound to be a frequent user need.

At 01:48 PM 5/9/2001, George A. Heintzelman wrote:

>> - 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.)
>Note that not all platforms support 64-bit ints directly. So you'll
>have to do some work if you want to support 32-bit machines with this

I wouldn't worry too much about that. Even on 32-bit machines many
compilers already support long long. Perhaps just use int_least64_t (see
boost/cstdint.hpp) as the underlying type.

That way there will be support from many current compilers, and as long
long rolls out then all compilers will eventually provide support.


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