Boost logo

Boost :

Subject: Re: [boost] [Boost.FixedPoint] Choose notation
From: Michael Marcin (mike.marcin_at_[hidden])
Date: 2013-04-29 03:35:08


On 4/29/2013 2:26 AM, Michael Marcin wrote:
> On 4/29/2013 1:46 AM, Andrey Semashev wrote:
>> Please, no cryptic abbreviations (and especially one letter names).
>>
>
> I've always felt that if floating point numbers are called float then
> fixed point numbers should be called fixed.
>
> fixed<24,8> representing a signed 24.8 fixed-point would be my preferred
> naming convention.
>
> It could be an alias for signed_fixed<24,8> much like int is for signed
> int. Then naturally if you needed to support unsigned fixed point types
> you could use unsigned_fixed<24,8>.
>
> I could see an argument made for fixed<int32_t,4> specifying the storage
> type and the radix, in this case 28.4. This handles the signed vs
> unsigned naturally and doesn't allow you to have (in my view) strange
> types like 8.4 which seems to require an odd 12bit integer type.
>
> If you absolutely needed an 8.4 type then you need fixed-width integer
> support beyond that provided by <cstdint>. You could provide an
> implementation of integer<12> that is a 12 bit integer and then make
> fixed<integer<12>,4>. In my opinion this is another library outside the
> scope of a fixed-point library.
>

There is also a possibility of both interfaces together I suppose.

template<
    std::size_t M,
    std::size_t F,
    typename Storage = typename boost::int_t<M+F>::least >
class fixed;


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