Hello ppl, I 've just written the following small fixed-point class:
template<typename I, Int32 N>
class Fixed
{
public:
Fixed();
Fixed(Float64 a_Float64) : value(a_Float64 * Pow(2.0, N))
{};
operator Float64()
{
return (Float64)value * Pow(2.0, -N);
};
Fixed<I, N> &operator=(Float64 a_Float64)
{
value = a_Float64 * Pow(2.0, N);
};
private:
I value;
};
where I is the underlying integral type and N is the number of bits to the right of the decimal point.
Now, i would like to do some typedefs like the following:
typedef Fixed<UInt64, N> UFixed64<N>;
but the above typedef generates errors (compiled with g++ 4.something):
Fixed.hpp:23: error: ‘N’ was not declared in this scope
Fixed.hpp:23: error: template argument 2 is invalid
Fixed.hpp:23: error: expected initializer before ‘<’ token
Is there any (preferably standard) way to do this kind of typedefs?