Subject: Re: [boost] GSOC 2013
From: Michael Marcin (mike.marcin_at_[hidden])
Date: 2013-04-23 19:05:11
On 4/23/13 5:24 PM, Vicente J. Botet Escriba wrote:
> Michael, I was not aware that you have already a fixed-point library in
> Could you give us pointer where this file cross/math/fixed/fixed.hpp is
Sure I had necro'd a thread a while back but it probably got missed.
On 2/1/13 11:09 PM, Michael Marcin wrote:>
> Missed this thread, only just came across it while catching up on things.
> I think fixed-point is a very worthwhile thing although in past
> discussions it seems like the functionality that everyone agrees upon is
> a very small subset of what people need in their fixed point types.
> I worked with fixed-point numbers for embedded systems without FPUs for
> a few years. Mostly doing real time 3d software rendering with fixed
> point numbers.
> I always imagined a boost fixed point library would use some expression
> template patterns probably built on boost proto and be a drop in
> replacement for float with no abstraction penalty. That way you could
> preserve full precision until the end of the full expression.
> Unfortunately I had neither the time or the TMP expertise to pull it
> off. Trig functions should be implemented with CORDIC-based algorithms.
> Here's the fixed point abstraction I used for reference.
> The main class acts as a drop in replacement for float.
> template< std::size_t MagnitudeBits, std::size_t FractionalBits >
> class fixed;
> The fixed class includes:
> - various converting constructors from integers, floating point, and
> different precision fixed-point types
> - comparison operators
> - arithmetic operators
> - some mixed type arithmetic operators (like fixed * int)
> - some really simple expression templates for multiplication
> as_fixed() function which takes an integral type and returns a type
> convertible to a fixed-point type
> fixed<16,16> a = as_fixed( 1<<16 );
> assert( a == fixed<16,16>(1) );
> numeric_limits is specialized for fixed types
> some math functions:
> - abs
> - fmod
> - floor
> - ceil
> - ceil_int
> - sqrt
> - sign_equal
> - sign_not_equal
> - *missing* true fixed-point trig functions
> conversion functions:
> - to_integer
> - to_float
> - to_double
> lame stream operators (convert to/from float):
> - std::istream& operator>>(std::istream& stream, fixed<M,F>& x)
> - std::ostream& operator<<(std::ostream& stream, const fixed<M,F>& x)
> Here's some interesting fixed-point resources
> Anthony Williams wrote an interesting article on fixed-point math.
> Nils Pipenbrinck wrote an interesting article of fixed-point math which
> all but disappeared unfortunately.
> Ken Turkowski's fixed-point square root algorithm
> ARM code inverse square root routines
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk