11#ifndef VRPN_FIXED_POINT_H_
12#define VRPN_FIXED_POINT_H_
31 struct IntegerOverflow;
88 template <
int BITS,
bool SIGNED = true>
105 template <
int INTEGER_BITS,
int FRACTIONAL_BITS,
bool SIGNED = true>
115 INTEGER_BITS + FRACTIONAL_BITS, SIGNED>::type
RawType;
145 : value_(x * (1 << FRACTIONAL_BITS))
149 : value_(x * (1 << FRACTIONAL_BITS))
160 template <
typename T> T
get()
const
162 return get(
reinterpret_cast<TypeWrapper<T> *
>(NULL));
172 template <
typename T>
struct TypeWrapper;
173 vrpn_float32
get(TypeWrapper<vrpn_float32> *)
const
175 return static_cast<vrpn_float32
>(value_) / (1 << FRACTIONAL_BITS);
178 vrpn_float64
get(TypeWrapper<vrpn_float64> *)
const
180 return static_cast<vrpn_float64
>(value_) / (1 << FRACTIONAL_BITS);
detail::IntegerOfSizeAndSignedness< INTEGER_BITS+FRACTIONAL_BITS, SIGNED >::type RawType
FixedPoint(typename detail::IntegerOfSizeAndSignedness< 8, SIGNED >::type x)
FixedPoint(typename detail::IntegerOfSizeAndSignedness< 16, SIGNED >::type x)
T get() const
Returns a floating-point representation of this fixed-point value.
FixedPoint(typename detail::IntegerOfSizeAndSignedness< 32, SIGNED >::type x)
detail::IntegerOfSizeAndSignedness< INTEGER_BITS, SIGNED >::type IntegerType
Find an integer type large enough to hold INTEGER_BITS.
Namespace enclosing internal implementation details.
IntegerOfSize< NUM_BITS+1 >::type type
UnsignedIntegerOfSize< NUM_BITS+1 >::type type