Boost logo

Boost :

Subject: Re: [boost] [Boost.FixedPoint] Choose notation
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2013-04-29 02:41:45


Le 29/04/13 00:18, Dmitriy Gorbel a écrit :
> Hello, community!
>
> I propose extending the Boost Libraries to provide binary
> fixed-point arithmetic, within GSOC project.
>
> Fixed-point library will provide nonnegative and negatable
> class templates for fractional arithmetic, and cardinal
> and integral for integer arithmetic. In total, four class templates.
>
> Fixed-point arithmetic use more than one notation, and I want
> to provide several notation to make happy all.
>
> Now I plan to implement two notations - Q notation and
> notation from C++1y proposal.
> Examples:
>
> C++1y proposal notation:
> cardinal<16> 0 <= n < 65536
> integral<4> -16 < n < 16
> nonnegative<8,-4> 0 <= n < 256 in increments of 2^-4 = 1/16
> negatable<16,-8> -65536 < n < 65536 in increments of 2^-8 = 1/256
>
> Q notation:
> cardinal<16> 0 <= n < 65536
> integral<4> -16 < n < 16
> nonnegative<8, 4> 0 <= n < 256 has 4 bit for fractional part
> negatable<16, 8> -65536 < n < 65536 has 8 bit for fractional part
>
> Please, help me to choose default notation, propose other
> notation, or just make any feedback.
>

I wonder if we need a default notation.
BTW, the choice of the names in the C++1y proposal was a source of
conflicts (as always).
In my prototype I used

fxp_uint and fxp_int
fxp_ufract and fxp_fract
(fxp_ufreal and fxp_real)

Now if you put these classes on a specific namespace for each notation
the choice of the default can be deferred without a major impact on the
plan.

namespace fixed_point {
   namespace q { }

   namespace cxx1y {}
   // if the default is cxx1y notation (a better name is welcome, e.g.
rr for range and resolution)
   using cxx1y::fxp_uint;
   using cxx1y::fxp_int;
   ...
}

With this approach the user could be precise enough

fixed_point::q::fxp_fract<8,4>;

we could also name the namespace for fixed points fxp and use

fxp::q::fract<8,4>;
fxp::rr::uinteger<8,4>;

Best,
Vicente

Best,
Vicente


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