![]() |
ChimeraTK-DeviceAccess 03.25.00
|
The fixed point converter provides conversion functions between a user type and up to 32 bit fixed point (signed or unsigned). More...
#include <FixedPointConverter.h>
Inheritance diagram for ChimeraTK::FixedPointConverter< RawType >:Classes | |
| struct | vectorToCooked_impl |
| struct | vectorToCooked_impl< std::string, RAW_ITERATOR, COOKED_ITERATOR > |
Public Member Functions | |
| FixedPointConverter (std::string variableName, unsigned int nBits=32, int fractionalBits=0, bool isSignedFlag=true) | |
| The constructor defines the conversion factor. | |
| template<typename UserType > | |
| RawType | toRaw (UserType cookedValue) const |
| Conversion function from type T to fixed point. | |
| template<typename UserType , typename RAW_ITERATOR , typename COOKED_ITERATOR > | |
| void | vectorToCooked (const RAW_ITERATOR &raw_begin, const RAW_ITERATOR &raw_end, const COOKED_ITERATOR &cooked_begin) const |
| Conversion function from fixed-point values to type T. | |
| template<typename UserType > | |
| UserType | scalarToCooked (RawType const &raw) const |
| Inefficient convenience function for converting a single value to cooked. | |
| unsigned int | getNBits () const |
| Read back the number of bits the converter is using. | |
| int | getFractionalBits () const |
| Read back the fractional bits the converter is using. | |
| bool | isSigned () const |
| Read back wether the conversion is using signed values. | |
| bool | operator== (const FixedPointConverter &other) const |
| Compare two fixed point converters. | |
| bool | operator!= (const FixedPointConverter &other) const |
The fixed point converter provides conversion functions between a user type and up to 32 bit fixed point (signed or unsigned).
Definition at line 31 of file FixedPointConverter.h.
|
explicit |
The constructor defines the conversion factor.
| variableName | The name of the variable. It is used in case an exception is thrown which significantly simplifies the debugging. |
| nBits | The number of total bits must not exceed 32. |
| fractionalBits | The number of fractional bits can range from -1024+nBits to 1021-nBits (in case of a double user type). For integer user types, no fractional bits are allowed. |
| isSignedFlag | Flag whether the most significant bit is interpreted as sign bit. Negative numbers are interpreted as two's complement number of the respective number of bits (i.e. in signed 6 bit, 0 fractional bits 0x3F is -1) |
Definition at line 497 of file FixedPointConverter.h.
|
inline |
Read back the fractional bits the converter is using.
Definition at line 101 of file FixedPointConverter.h.
|
inline |
Read back the number of bits the converter is using.
Definition at line 98 of file FixedPointConverter.h.
|
inline |
Read back wether the conversion is using signed values.
Definition at line 104 of file FixedPointConverter.h.
|
inline |
Definition at line 111 of file FixedPointConverter.h.
|
inline |
Compare two fixed point converters.
The variable name is ignored in this comparison.
Definition at line 108 of file FixedPointConverter.h.
|
inline |
Inefficient convenience function for converting a single value to cooked.
Definition at line 91 of file FixedPointConverter.h.
| RawType ChimeraTK::FixedPointConverter< RawType >::toRaw | ( | UserType | cookedValue | ) | const |
Conversion function from type T to fixed point.
This conversion usually will introduce rounding errors due to this limited resolution of the fixed point number compared to the double. In case of a high number of fractional bits this can mean that the most significant digits are cut and only the 'noise' in the less significant bits is represented.
Definition at line 341 of file FixedPointConverter.h.
|
inline |
Conversion function from fixed-point values to type T.
The two vectors passed must be of equal size (i.e. cookedValues must already be properly allocated).
Definition at line 64 of file FixedPointConverter.h.