Interest for a Fixed Point Arithmetics library

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Interest for a Fixed Point Arithmetics library

Boost - Dev mailing list
Hello everybody.
I am working on a project that needs and can use fixed point numbers, so I
started searching for a library implementing fixed point numbers, but I
didn't find anything. So I was wondering if people would need fixed point
arithmetics, and here I am.

The aim of this FixedPointNumber is to fix the point at compile-time using
template, and having another template argument for the underlying type.
So we have :

    template<typename T, size_t N>
    class FixedPointNumber {
        T value;
    public:
        //interface
    };

The N last bits of value is the decimal part : so to convert a
FixedPointNumber to an int, we need only to use a bitshift operator (and
same for construction from int).
sizeof(FixedPointNumber<T,N>) == sizeof(T) , so there is no overhead in
this implementation.
Arithmetic and relational operators will be implemented.
Multiplication needs one int multiplication and one bit shift.
Division needs one int division and one bit shift.
There is only one value for zero.
Sign can be extracted with Most Significant Bit.

I have already a basic implementation but if it interests more people I
will do a proper implementation.

Thank you for reading !

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: Interest for a Fixed Point Arithmetics library

Boost - Dev mailing list


> -----Original Message-----
> From: Boost [mailto:[hidden email]] On Behalf Of Julien Vernay via Boost
> Sent: 30 December 2017 18:30
> To: [hidden email]
> Cc: Julien Vernay
> Subject: [boost] Interest for a Fixed Point Arithmetics library
>
> Hello everybody.
> I am working on a project that needs and can use fixed point numbers, so I
> started searching for a library implementing fixed point numbers, but I
> didn't find anything. So I was wondering if people would need fixed point
> arithmetics, and here I am.
>
> The aim of this FixedPointNumber is to fix the point at compile-time using
> template, and having another template argument for the underlying type.
> So we have :
>
>     template<typename T, size_t N>
>     class FixedPointNumber {
>         T value;
>     public:
>         //interface
>     };
>
> The N last bits of value is the decimal part : so to convert a
> FixedPointNumber to an int, we need only to use a bitshift operator (and
> same for construction from int).
> sizeof(FixedPointNumber<T,N>) == sizeof(T) , so there is no overhead in
> this implementation.
> Arithmetic and relational operators will be implemented.
> Multiplication needs one int multiplication and one bit shift.
> Division needs one int division and one bit shift.
> There is only one value for zero.
> Sign can be extracted with Most Significant Bit.
>
> I have already a basic implementation but if it interests more people I
> will do a proper implementation.

An implementation of fixed-point has been written (and is in real-life use) by Chris Kormanyos

see https://github.com/BoostGSoC15/fixed_point/

this uses a specified (fixed at compile-time) fixed-point format.  Big formats are possible and it works seamlessly with many
Boost.Math functions, often using constexpr for compile-time computations).

It did not receive much attention when tentatively proposed for Boost.

C++ standards groups are also considering a proposal for an 'elastic' (at run-time) fixed-point library by John Macfarlane

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0554r0.html

I suggest you should study these different approaches (not necessarily mutually exclusive)?

Paul

---
Paul A. Bristow
Prizet Farmhouse
Kendal UK LA8 8AB
+44 (0) 1539 561830









_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: Interest for a Fixed Point Arithmetics library

Boost - Dev mailing list
On December 31, 2017 6:50:01 PM "Paul A. Bristow via Boost"
<[hidden email]> wrote:

>
>
>> -----Original Message-----
>> From: Boost [mailto:[hidden email]] On Behalf Of Julien
>> Vernay via Boost
>> Sent: 30 December 2017 18:30
>> To: [hidden email]
>> Cc: Julien Vernay
>> Subject: [boost] Interest for a Fixed Point Arithmetics library
>>
>> Hello everybody.
>> I am working on a project that needs and can use fixed point numbers, so I
>> started searching for a library implementing fixed point numbers, but I
>> didn't find anything. So I was wondering if people would need fixed point
>> arithmetics, and here I am.
>>
>> The aim of this FixedPointNumber is to fix the point at compile-time using
>> template, and having another template argument for the underlying type.
>> So we have :
>>
>>     template<typename T, size_t N>
>>     class FixedPointNumber {
>>         T value;
>>     public:
>>         //interface
>>     };
>>
>> The N last bits of value is the decimal part : so to convert a
>> FixedPointNumber to an int, we need only to use a bitshift operator (and
>> same for construction from int).
>> sizeof(FixedPointNumber<T,N>) == sizeof(T) , so there is no overhead in
>> this implementation.
>> Arithmetic and relational operators will be implemented.
>> Multiplication needs one int multiplication and one bit shift.
>> Division needs one int division and one bit shift.
>> There is only one value for zero.
>> Sign can be extracted with Most Significant Bit.
>>
>> I have already a basic implementation but if it interests more people I
>> will do a proper implementation.
>
> An implementation of fixed-point has been written (and is in real-life use)
> by Chris Kormanyos
>
> see https://github.com/BoostGSoC15/fixed_point/
>
> this uses a specified (fixed at compile-time) fixed-point format.  Big
> formats are possible and it works seamlessly with many
> Boost.Math functions, often using constexpr for compile-time computations).
>
> It did not receive much attention when tentatively proposed for Boost.

Is this proposal stalled? I vaguely remember a fixed-point proposal but I
don't remember the details.

I'm interested in a fast compile-time configured fixed-point type as I had
to write one for one project.




_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: Interest for a Fixed Point Arithmetics library

Boost - Dev mailing list


> -----Original Message-----
> From: Boost [mailto:[hidden email]] On Behalf Of Andrey Semashev via Boost
> Sent: 31 December 2017 16:14
> To: [hidden email]
> Cc: Andrey Semashev
> Subject: Re: [boost] Interest for a Fixed Point Arithmetics library
>
> On December 31, 2017 6:50:01 PM "Paul A. Bristow via Boost"
> <[hidden email]> wrote:
>
> >
> >
> >> -----Original Message-----
> >> From: Boost [mailto:[hidden email]] On Behalf Of Julien
> >> Vernay via Boost
> >> Sent: 30 December 2017 18:30
> >> To: [hidden email]
> >> Cc: Julien Vernay
> >> Subject: [boost] Interest for a Fixed Point Arithmetics library
> >>
> >> Hello everybody.
> >> I am working on a project that needs and can use fixed point numbers, so I
> >> started searching for a library implementing fixed point numbers, but I
> >> didn't find anything. So I was wondering if people would need fixed point
> >> arithmetics, and here I am.
> >>
> >> The aim of this FixedPointNumber is to fix the point at compile-time using
> >> template, and having another template argument for the underlying type.
> >> So we have :
> >>
> >>     template<typename T, size_t N>
> >>     class FixedPointNumber {
> >>         T value;
> >>     public:
> >>         //interface
> >>     };
> >>
> >> The N last bits of value is the decimal part : so to convert a
> >> FixedPointNumber to an int, we need only to use a bitshift operator (and
> >> same for construction from int).
> >> sizeof(FixedPointNumber<T,N>) == sizeof(T) , so there is no overhead in
> >> this implementation.
> >> Arithmetic and relational operators will be implemented.
> >> Multiplication needs one int multiplication and one bit shift.
> >> Division needs one int division and one bit shift.
> >> There is only one value for zero.
> >> Sign can be extracted with Most Significant Bit.
> >>
> >> I have already a basic implementation but if it interests more people I
> >> will do a proper implementation.
> >
> > An implementation of fixed-point has been written (and is in real-life use)
> > by Chris Kormanyos
> >
> > see https://github.com/BoostGSoC15/fixed_point/
> >
> > this uses a specified (fixed at compile-time) fixed-point format.  Big
> > formats are possible and it works seamlessly with many
> > Boost.Math functions, often using constexpr for compile-time computations).
> >
> > It did not receive much attention when tentatively proposed for Boost.
>
> Is this proposal stalled? I vaguely remember a fixed-point proposal but I
> don't remember the details.
>
> I'm interested in a fast compile-time configured fixed-point type as I had
> to write one for one project.

It is working and in 'real-life' use 'in anger', and reasonably documented with examples of usage.

But nobody in Boost seemed to be at all interested, so it wasn't proposed formally.

Paul

---
Paul A. Bristow
Prizet Farmhouse
Kendal UK LA8 8AB
+44 (0) 1539 561830




_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: Interest for a Fixed Point Arithmetics library

Boost - Dev mailing list
On 01/01/18 15:27, Paul A. Bristow via Boost wrote:

>
>
>> -----Original Message-----
>> From: Boost [mailto:[hidden email]] On Behalf Of Andrey Semashev via Boost
>> Sent: 31 December 2017 16:14
>> To: [hidden email]
>> Cc: Andrey Semashev
>> Subject: Re: [boost] Interest for a Fixed Point Arithmetics library
>>
>> On December 31, 2017 6:50:01 PM "Paul A. Bristow via Boost"
>> <[hidden email]> wrote:
>>>
>>> An implementation of fixed-point has been written (and is in real-life use)
>>> by Chris Kormanyos
>>>
>>> see https://github.com/BoostGSoC15/fixed_point/
>>>
>>> this uses a specified (fixed at compile-time) fixed-point format.  Big
>>> formats are possible and it works seamlessly with many
>>> Boost.Math functions, often using constexpr for compile-time computations).
>>>
>>> It did not receive much attention when tentatively proposed for Boost.
>>
>> Is this proposal stalled? I vaguely remember a fixed-point proposal but I
>> don't remember the details.
>>
>> I'm interested in a fast compile-time configured fixed-point type as I had
>> to write one for one project.
>
> It is working and in 'real-life' use 'in anger', and reasonably documented with examples of usage.
>
> But nobody in Boost seemed to be at all interested, so it wasn't proposed formally.

Well, I'm interested. :) Is there a chance it will be proposed?

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: Interest for a Fixed Point Arithmetics library

Boost - Dev mailing list
It seems there is at least some people interested so I will propose it
finished for reviewing it :)

2018-01-01 13:41 GMT+01:00 Andrey Semashev via Boost <[hidden email]>
:

> On 01/01/18 15:27, Paul A. Bristow via Boost wrote:
>
>>
>>
>> -----Original Message-----
>>> From: Boost [mailto:[hidden email]] On Behalf Of Andrey
>>> Semashev via Boost
>>> Sent: 31 December 2017 16:14
>>> To: [hidden email]
>>> Cc: Andrey Semashev
>>> Subject: Re: [boost] Interest for a Fixed Point Arithmetics library
>>>
>>> On December 31, 2017 6:50:01 PM "Paul A. Bristow via Boost"
>>> <[hidden email]> wrote:
>>>
>>>>
>>>> An implementation of fixed-point has been written (and is in real-life
>>>> use)
>>>> by Chris Kormanyos
>>>>
>>>> see https://github.com/BoostGSoC15/fixed_point/
>>>>
>>>> this uses a specified (fixed at compile-time) fixed-point format.  Big
>>>> formats are possible and it works seamlessly with many
>>>> Boost.Math functions, often using constexpr for compile-time
>>>> computations).
>>>>
>>>> It did not receive much attention when tentatively proposed for Boost.
>>>>
>>>
>>> Is this proposal stalled? I vaguely remember a fixed-point proposal but I
>>> don't remember the details.
>>>
>>> I'm interested in a fast compile-time configured fixed-point type as I
>>> had
>>> to write one for one project.
>>>
>>
>> It is working and in 'real-life' use 'in anger', and reasonably
>> documented with examples of usage.
>>
>> But nobody in Boost seemed to be at all interested, so it wasn't proposed
>> formally.
>>
>
> Well, I'm interested. :) Is there a chance it will be proposed?
>
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman
> /listinfo.cgi/boost
>

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: Interest for a Fixed Point Arithmetics library

Boost - Dev mailing list
On Mon, Jan 1, 2018 at 4:25 PM, Julien Vernay via Boost
<[hidden email]> wrote:

> 2018-01-01 13:41 GMT+01:00 Andrey Semashev via Boost <[hidden email]>
> :
>> On 01/01/18 15:27, Paul A. Bristow via Boost wrote:
>>
>>> But nobody in Boost seemed to be at all interested, so it wasn't proposed
>>> formally.
>>
>> Well, I'm interested. :) Is there a chance it will be proposed?
>>
> It seems there is at least some people interested so I will propose it
> finished for reviewing it :)

Thanks. I'll be looking forward to it.

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: Interest for a Fixed Point Arithmetics library

Boost - Dev mailing list
In reply to this post by Boost - Dev mailing list
> Is this proposal stalled? I vaguely remember a fixed-point> proposal but I don't remember the details.
In my opinion, the proposal was halted on purpose,or not forced to continue might be a better way ofputting it...
There were several reasons.
1) There was some, but not much, interest in the review.2) There is a slight conflict between the proposedboost::Fixed_point and the work of C++ standards groups,Mr. Macfarlane and SG14. In the Boost proposal,bound arithmetic is the default (unbound not supported).Whereas in the proposal for the standard, unboundarithmetic is the default, but both bound and unboundare supported.3) The work for Boost only supports 1 fixed-point type(similar to negatable). But the standards work supports4 types used for both signed and unsigned manipulationof both fractional and integral representations.
4) The work for Boost only supports 2 rounding modes.But the standards work supports 5.5) A few other details.

At the time, it was difficult for us to overcomethe slight discrepancies in these two bodies ofwork, in particular number 2 above.
The work for Boost is, nonetheless, available.It is tested and documented, but onlyfor what it does.

Best regards, Chris
 

    On Sunday, December 31, 2017, 5:14:06 PM GMT+1, Andrey Semashev via Boost <[hidden email]> wrote:  
 
 On December 31, 2017 6:50:01 PM "Paul A. Bristow via Boost"
<[hidden email]> wrote:

>
>
>> -----Original Message-----
>> From: Boost [mailto:[hidden email]] On Behalf Of Julien
>> Vernay via Boost
>> Sent: 30 December 2017 18:30
>> To: [hidden email]
>> Cc: Julien Vernay
>> Subject: [boost] Interest for a Fixed Point Arithmetics library
>>
>> Hello everybody.
>> I am working on a project that needs and can use fixed point numbers, so I
>> started searching for a library implementing fixed point numbers, but I
>> didn't find anything. So I was wondering if people would need fixed point
>> arithmetics, and here I am.
>>
>> The aim of this FixedPointNumber is to fix the point at compile-time using
>> template, and having another template argument for the underlying type.
>> So we have :
>>
>>    template<typename T, size_t N>
>>    class FixedPointNumber {
>>        T value;
>>    public:
>>        //interface
>>    };
>>
>> The N last bits of value is the decimal part : so to convert a
>> FixedPointNumber to an int, we need only to use a bitshift operator (and
>> same for construction from int).
>> sizeof(FixedPointNumber<T,N>) == sizeof(T) , so there is no overhead in
>> this implementation.
>> Arithmetic and relational operators will be implemented.
>> Multiplication needs one int multiplication and one bit shift.
>> Division needs one int division and one bit shift.
>> There is only one value for zero.
>> Sign can be extracted with Most Significant Bit.
>>
>> I have already a basic implementation but if it interests more people I
>> will do a proper implementation.
>
> An implementation of fixed-point has been written (and is in real-life use)
> by Chris Kormanyos
>
> see https://github.com/BoostGSoC15/fixed_point/
>
> this uses a specified (fixed at compile-time) fixed-point format.  Big
> formats are possible and it works seamlessly with many
> Boost.Math functions, often using constexpr for compile-time computations).
>
> It did not receive much attention when tentatively proposed for Boost.

Is this proposal stalled? I vaguely remember a fixed-point proposal but I
don't remember the details.

I'm interested in a fast compile-time configured fixed-point type as I had
to write one for one project.




_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
 

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost