|
Boost : |
From: Jeff Garland (jeff_at_[hidden])
Date: 2005-01-08 15:46:26
On Sat, 8 Jan 2005 14:36:48 +0000 (UTC), Martin wrote
> (I know that "Currency" received 0 votes at the OOPSALA conference
> but maybe someone is interested anyway)
I was at OOPSLA and I think everyone needs to keep in mind that not having a
vote at OOPSLA does not imply there is no interest in a library or category.
Obviously we had a very small subsection of boosters to sample and their
priorities might not match with many other boosters priorities. Also, the
fact that it was discussed and on the list means that there is at least some
interest.
Anyway, I'm interested in these libraries even though I don't have an app that
would use this right this minute. Here's my reasoning. To my way of thinking
there is tremendous leverage to be gained in the use of well-tested value
types in codification of interfaces, hiding of complex domain rules, and
overall simplification of code. Kevlin Henney has written some articles on
this (http://www.two-sdg.demon.co.uk/curbralan/papers.html). So on my
'library roadmap' (wiki page: http://tinyurl.com/6v5vx) I have a category
called 'value types' where I have a list of these libraries I'd like to see in
boost (your's is one of them :-)
> I have implemented a type for handling decimal math and a type
> specialized for monetary values.
>
> decimal64 type
> -------------
> The type stores a decimal value with specified numberof decimals
> exactly and also performs all arithmetic operations (+,-,*,/) using
> decimal math.
>
> (Internally the type stores the value as an int64 value which gives
> 18 DECIMAL digits precision. Multiply and divide uses a 128 bit
> temporay to avoid rounding errors)
>
> - All std rounding modes are available plus a few extra such
> as round_to_even.
Can you enumerate 'std rounding modes'?
> There are 2 decimal64 types defined:
>
> - decimal64 - all constructors requires specification of number of
> decimals and optionally rounding mode.
>
> decimal64(3.1415, 4, round_to_nearest);
>
> - decimal64_spec - a template version of decimal64 where number of
> decimals and rounding mode are specified as template parameters
> which allows a default constructor.
>
> typedef decimal64_spec<3, round_to_even> decimal3;
> decimal3 x(3.14), y;
Cool.
>...snip...
>
> Some things I would specificly like to have comments on:
>
> 1. Operations are not allowed on doubles. Double values always need
> to be converted into a decimal value first. e.g. x * decimal64(3.14,
>
> 2). Is this something that is needed?
Seems reasonable to me.
> 2. No overflow detection or +inf etc. Just like with the integer
> types there is no checking for overflow on operations.
Again probably a reasonable compromise.
> Money type
>...snip...
>
> locale library
> --------------
> Some time ago implemented helper classes for locale but I never got
> around submitting it to boost. I needed it for testing the
> decimal64/money streaming so I cleaned it up and it is included in
> the package.
I'll try and take a look at this as I have some of this type of code for
date-time.
Jeff
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk