Boost logo

Boost :

From: Bill Seymour (bill-at-the-office_at_[hidden])
Date: 2002-09-04 08:11:19


Stephen Nutt wrote:
>
> I took a brief look at thw fixed point work going on
> in J11/WG14, but confess I've yet to read all 91 pages.
>

Me, too. 8-) The fixed-point stuff is only about 40 pages
(clause 2 and annex A), much of it skimmable because it
clearly wouldn't apply to a C++ library (pragmas, printf
format specifiers, fixed-point literals, etc.).

>
> Is a policy a template parameter?
>

Yes, a template parameter that's also inherited so that
it can effect interface as well as behavior. I echo
Beman's recommendation of Alexandrescu, /Modern C++
Design/. IMO, it's well worth a careful read.

I'm thinking of something like

    class sat;
    class modwrap;

    template<class IntType, bool HasIntPart, class Overflow>
    class fixed_point_binary : public Overflow
    {
        // ...
    };

Then a user concerned with C/C++ compatibility could write

    #if defined(__cplusplus)

        typedef boost::fixed_point_binary<unsigned,
           true, boost::sat> unsigned_sat_accum;

    #else

        typedef unsigned _Sat _Accum unsigned_sat_accum;

    #endif

>
> I didn't know there was a cheap and easy way to get 2ulp.
> All my calculations are currently 1ulp but I can reconsider
> my multiply and divide for an optional and faster 2ulp.
>

I now think this probably doesn't matter unless you're scaling
down a double-precision product with shifts and adds. (IIRC,
it doesn't apply to division.)

--Bill Seymour


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