Boost logo

Boost :

From: Bill Seymour (bill-at-the-office_at_[hidden])
Date: 2002-03-10 08:42:54


Jeff wrote:
>
> The use of the term precision (despite any C++ precedent)
> I think is actually incorrect.
>

It's a common usage that folks are likely to understand...
kind of like using "data" as a mass noun instead of the
plural of "datum."

>
> I not sure I see the need for the rounding function base class.
>

I wanted to put computationally expensive routines in a .cpp file
so that the header wouldn't have all that code that has to be
compiled every time. Absent the ability to export templates,
I need a non-template base class.

>
> Speaking of the operators, it would be nice to see a quick
> synopsis of showing the 'proxy' operators in action.
>

I have the example,

    euros = francs * bankers_round(conversion_rate);

near the beginning of the paper. Should I explain it better?

>
> The only examples are in the policy design section which is
> what we "can't" do.
>

I don't understand what you mean.

>
> The default rounding mode selection by macro is odd to me.
> I would much rather see the policy-based template implementation
> you reject later in the paper. To me one additional template
> parameter is much easier to understand for the user than a 'macro'
> parameter. I would be fine with having to 'cast' decimals with
> different rounding modes to a compatible type to perform operations.
>

The real issue is not the number of template parameters; that was
just an additional argument that I threw in as an afterthought.
The fundamental issue is whether the rounding mode should bind
to the operation or to the operand. If you can convince me that
the latter is the better design, I'll be happy to change it.

>
> ... the I/O functions should be in a decimal_io.hpp file
> to avoid extra io includes.
>

I hadn't thought of that. I understand that many folks don't
want to include <iostream> in every compile; so this is a change
that I'll make.

>
> I would like to see a to_string function added.
>

OK. How about (modulo your objections to "precision" and
the macro for the default rounding mode):

    template<int Precision>
    class decimal
    {
    public:
        // ...

        std::string to_string(int = Precision,
          const rounding_base& =
            BOOST_DEFAULT_ROUNDING_MODE< decimal<Precision> >());
    };

Would that work for you? (Actualy, I already have a to_string
function in a privately inherited base class that I could just
dispatch to.)

--Bill


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk