From: Paul A. Bristow (boost_at_[hidden])
Date: 2003-02-27 14:15:56
Yes - this looks potentially rather useful for some tasks, especially embedded
Why on earth didn't the language include fixed point and/or fractional types?
As you observe, the increased accuracy compared to float (just a little too
small for some measurements like weights) but with half the memory of double,
and of course the integer/binary nature are sometimes useful.
Do you have any test programs?
Have you made any comparison with float and double speeds?
HTH to encourage you.
Paul A Bristow, Prizet Farmhouse, Kendal, Cumbria, LA8 8AB UK
+44 1539 561830 Mobile +44 7714 33 02 04
> -----Original Message-----
> From: boost-bounces_at_[hidden]
> [mailto:boost-bounces_at_[hidden]]On Behalf Of Kevin Atkinson
> Sent: Thursday, February 27, 2003 2:29 AM
> To: Boost mailing list
> 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
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk