11 #ifndef VRPN_FIXED_POINT_H_ 12 #define VRPN_FIXED_POINT_H_ 31 struct IntegerOverflow;
80 template <
int INTEGER_BITS,
int FRACTIONAL_BITS>
class FixedPoint {
128 : value_(x * (1 << FRACTIONAL_BITS))
132 : value_(x * (1 << FRACTIONAL_BITS))
143 template <
typename T> T
get()
const 145 return get(
reinterpret_cast<TypeWrapper<T> *
>(NULL));
155 template <
typename T>
struct TypeWrapper;
156 vrpn_float32
get(TypeWrapper<vrpn_float32> *)
const 158 return static_cast<vrpn_float32
>(value_) / (1 << FRACTIONAL_BITS);
161 vrpn_float64
get(TypeWrapper<vrpn_float64> *)
const 163 return static_cast<vrpn_float64
>(value_) / (1 << FRACTIONAL_BITS);
171 #endif // VRPN_FIXED_POINT_H_
FixedPoint(vrpn_uint16 x)
detail::IntegerOfSize< INTEGER_BITS >::type IntegerType
Find an integer type large enough to hold INTEGER_BITS.
Namespace enclosing internal implementation details.
detail::IntegerOfSize< INTEGER_BITS+FRACTIONAL_BITS >::type RawType
FixedPoint(vrpn_uint32 x)
IntegerOfSize< NUM_BITS+1 >::type type
A fixed-point value class.