namespace boostish { namespace math { template inline fixed::fixed() { } template inline fixed::fixed( int n ) : data(n << fractional_bits) { } template inline fixed::fixed( float n ) : data(static_cast( n * one )) { } template inline fixed::fixed( double n ) : data(static_cast( n * one )) { } template inline fixed::fixed( const fixed &rhs ) : data(rhs.data) { } template inline fixed::fixed( detail::raw_fixed raw ) : data(raw.data) { } template inline fixed& fixed::operator = ( const fixed &rhs ) { data = rhs.data; return *this; } template inline bool fixed::operator < ( const fixed &rhs ) const { return data < rhs.data; } template inline bool fixed::operator == ( const fixed &rhs ) const { return data == rhs.data; } template inline fixed& fixed::operator += ( const fixed &n ) { data += n.data; return *this; } template inline fixed& fixed::operator -= ( const fixed &n ) { data -= n.data; return *this; } template inline fixed& fixed::operator *= ( const fixed &n ) { next_type t(static_cast(data) * static_cast(n.data)); t >>= fractional_bits; data = static_cast(t); return *this; } template inline fixed& fixed::operator /= ( const fixed &n ) { next_type t(static_cast(data)); t <<= fractional_bits; t /= static_cast(n.data); data = static_cast(t); return *this; } template inline fixed& fixed::operator ++ () { data += base_type(1) << fractional_bits; return *this; } template inline fixed& fixed::operator -- () { data -= base_type(1) << fractional_bits; return *this; } template inline fixed& fixed::operator *= ( int n ) { data *= n; return *this; } template inline fixed& fixed::operator /= ( int n ) { data /= n; return *this; } template inline fixed operator * ( fixed lhs, int rhs ) { return lhs *= rhs; } template inline fixed operator * ( int lhs, fixed rhs ) { return rhs *= lhs; } template inline fixed operator / ( fixed lhs, int rhs ) { return lhs /= rhs; } template inline int to_integer( const fixed &f ) { return f.data >> fixed::fractional_bits; } template inline float to_float( const fixed &f ) { return static_cast( f.data ) / float( fixed::one ); } template inline double to_double( const fixed &f ) { return static_cast( f.data ) / double( fixed::one ); } } // end namespace math } // end namespace method