|
Boost : |
From: Stephen Nutt (snutt_at_[hidden])
Date: 2003-03-01 09:43:40
----- Original Message -----
From: "Kevin Atkinson" <kevin_at_[hidden]>
To: "Boost mailing list" <boost_at_[hidden]>
Sent: Saturday, March 01, 2003 12:03 AM
Subject: Re: [boost] Is there any Interest in a Fixed Point Library?
> On Fri, 28 Feb 2003, Stephen Nutt wrote:
>
> > Kevin,
> >
> > I started on this must be close to a year ago, and I got wrapped up with
> > other stuff and never got back to it.
>
> Well I don't have a large interest in it beyond simple arithmetic. The
> main reason that I wrote is to avoid having to deal with portably sending
> floating point numbers over the network. With integers all I have to
> worry about is endian order.
>
> > One nifty option was to specify what would happen on overflow. There
were
> > two choices. Either the number would not overflow but go to its limit,
or
> > it would overflow in the 'expected' way.
>
> Yes I know what you mean. The problem is doing it efficiently.
>
Efficiency was one key aspect of my design. So I used trait classes to
handle the arithmetic. This way you could either use the highly efficent
overflow traits (should be as efficient as doing fixed point arithmetic
without a template with a decent compiler), or use the saturation traits
class, which will increase compiled code size and reduce speed. Althought I
don't need the saturation aspect for my purposes, fot the template class to
be useful for the embedded folks, it seemed to be necessary.
> > fixed <int, 6> a = val1;
> > fixed <char, 3> b = val2;
> > fixed <long, 9> = a + b;
> >
> > without loss of precision.
>
> Can you post the implementation?
>
I'll take a look for it and see if I can clean it up a little. I'll try and
post it by the end of the weekend.
> --
> http://kevin.atkinson.dhs.org
>
> _______________________________________________
> Unsubscribe & other changes:
http://lists.boost.org/mailman/listinfo.cgi/boost
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk