Boost logo

Boost :

From: Stephen Nutt (snutt_at_[hidden])
Date: 2003-02-28 20:04:52


Found it. A long read, but interesting.

http://anubis.dkuug.dk/JTC1/SC22/WG14/www/docs/n972.pdf.

To give credit where it is due, Bill Seymour sent me the URL back in August
of last year. (Guess is was only 6 months ago I was doing this.)

----- Original Message -----
From: "Stephen Nutt" <snutt_at_[hidden]>
To: "Boost mailing list" <boost_at_[hidden]>
Sent: Friday, February 28, 2003 7:48 PM
Subject: Re: [boost] Is there any Interest in a Fixed Point Library?

> 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.
>
> A couple of interesting design ideas. Someone (sorry I forget who)
pointed
> me towards a great pdf file describing a fixed point arithmetic
enhancement
> for embedded compilers. It was very cool, and had some great ideas.
>
> 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. (Did that make sense?)
>
> So if I had a class
> fixed<unsigned char, 3> a = 3.0; // 8 bit fixed point number with three
> significant bits
>
> a * 3 would either give me 7.96875 or 1.0 A possible third choice would
be
> to raise an exception on overflow/underflow.
>
> My personal interest in the template was for a highly efficient 64 bit
fixed
> point number. As it turned out, there was no 64 bit support in Boost at
the
> time, and getting it turned out to be more of a pain than I had time for!
> It may be there now as I think I've seen others look for this also since.
>
> I put together some great templates so I could do arithmetic like
>
> fixed <int, 6> a = val1;
> fixed <char, 3> b = val2;
> fixed <long, 9> = a + b;
>
> without loss of precision.
>
> I also have templates to do 64 bit arbitary fractional multiplication and
> division without loss of precision. I also have a 64 bit squareroot
> function lurking somewhere in the depths of my harddrive. I'm not sure
how
> all of this would work if the type was say complex, but I'm sure it could
be
> worked on.
>
> I'll look for the pdf I mentioned above and if I find it I'll post a url.
I
> think this is a great place to start as I believe there is a reasonable
> demand for fixed point arithemetic in embedded computers.
>
> Stephen
>
> ----- Original Message -----
> From: "Kevin Atkinson" <kevin_at_[hidden]>
> To: "Boost mailing list" <boost_at_[hidden]>
> Sent: Wednesday, February 26, 2003 9:28 PM
> Subject: [boost] Is there any Interest in a Fixed Point Library?
>
>
> >
> > Is there any interest in a fixed point math library. Using templates
the
> > compiler can keep track of the radix point for you making using fixed
> > point math a lot less tedious and error prone.
> >
> > Attached is a rudimentary implementation which would work acceptably
when
> > the exponent is not too large or too small. If the exponent is smaller
or
> > larger than the size of the underlying integer in bits this code will
> > likely behave badly.
> >
> > I plan to use the attached code to avoid having to deal with serializing
> > floating point numbers. A exponent of -30 (-31 if using an unsigned 32
> > bit integer) is especially useful for representing numbers between 0 and
> > 1. The precision will actually be a bit better than a 32 bit float
since
> > the exponent does not have to be stored.
> >
> > Comments on the code welcome. I am not a numerical analysis specialist
so
> > don't expect me to write a fixed point library for anything beyond
simple
> > arithmetic.
> >
> > --
> > 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