|
Open Model Railroad Network (OpenMRN)
|
Public Types | |
| enum | FromDouble { FROM_DOUBLE } |
Public Member Functions | |
| constexpr | Fixed16 (int16_t integer, uint16_t frac=0) |
| Constructs a Fixed16. | |
| constexpr | Fixed16 (FromDouble, double value) |
| Constructs a Fixed16. | |
| Fixed16 (const Fixed16 &o)=default | |
| Fixed16 & | operator= (const Fixed16 &o)=default |
| Fixed16 & | operator+= (Fixed16 o) |
| template<class T > | |
| Fixed16 | operator+ (T o) const |
| Fixed16 & | operator-= (Fixed16 o) |
| template<typename T > | |
| Fixed16 | operator- (T o) const |
| Fixed16 & | operator*= (Fixed16 o) |
| template<typename T > | |
| Fixed16 | operator* (T o) const |
| Fixed16 & | operator/= (Fixed16 o) |
| template<typename T > | |
| Fixed16 | operator/ (T o) const |
| bool | operator< (Fixed16 o) |
| Comparison operator. | |
| bool | operator<= (Fixed16 o) |
| Comparison operator. | |
| bool | operator> (Fixed16 o) |
| Comparison operator. | |
| bool | operator>= (Fixed16 o) |
| Comparison operator. | |
| bool | operator== (Fixed16 o) |
| Comparison operator. | |
| bool | operator!= (Fixed16 o) |
| Comparison operator. | |
| Fixed16 & | mulpow2 (Fixed16 o) |
| Multiplies *this with pow(2, o). | |
| int16_t | round () const |
| int16_t | trunc () const |
| uint16_t | frac () const |
| float | to_float () const |
| bool | is_positive () const |
| void | negate () |
| int32_t | to_key () |
| Turns the value into a comparison key. | |
Private Member Functions | |
| int32_t | to_int () const |
| Translates the current value to a signed fixed-point 32-bit integer. | |
| void | from_int (int32_t v) |
| Overwrites the current value from a signed fixed-point 32-bit integer. | |
Private Attributes | |
| uint32_t | value_: 31 |
| uint32_t | sign_: 1 |
Definition at line 42 of file Fixed16.hxx.
| enum Fixed16::FromDouble |
Definition at line 57 of file Fixed16.hxx.
|
inlineconstexpr |
Constructs a Fixed16.
| integer | is the integer part and the sign. Valid values are from -32767 to 32767. |
| frac | is the fractional part. All uint16 values are valid. For positive integer the fractional part goes above the int value, for negative integers the fractional part goes below the int value. |
Definition at line 51 of file Fixed16.hxx.
|
inlineconstexpr |
Constructs a Fixed16.
| value | is the value to store. Valid values are -32767.99999 to 32767.99999. |
Definition at line 65 of file Fixed16.hxx.
|
inline |
Definition at line 242 of file Fixed16.hxx.
|
inlineprivate |
Overwrites the current value from a signed fixed-point 32-bit integer.
Definition at line 312 of file Fixed16.hxx.
|
inline |
Definition at line 282 of file Fixed16.hxx.
Multiplies *this with pow(2, o).
This is effectively a generalized shift operation that works on fractional numbers too. The precision is limited.
Modifies *this.
| o | number of "bits" to shift with. May be positive or negative. |
Definition at line 181 of file Fixed16.hxx.
|
inline |
Definition at line 286 of file Fixed16.hxx.
Comparison operator.
Definition at line 169 of file Fixed16.hxx.
|
inline |
Definition at line 113 of file Fixed16.hxx.
Definition at line 103 of file Fixed16.hxx.
|
inline |
Definition at line 83 of file Fixed16.hxx.
Definition at line 77 of file Fixed16.hxx.
|
inline |
Definition at line 96 of file Fixed16.hxx.
Definition at line 90 of file Fixed16.hxx.
|
inline |
Definition at line 131 of file Fixed16.hxx.
Definition at line 120 of file Fixed16.hxx.
Comparison operator.
Definition at line 139 of file Fixed16.hxx.
Comparison operator.
Definition at line 145 of file Fixed16.hxx.
Comparison operator.
Definition at line 163 of file Fixed16.hxx.
Comparison operator.
Definition at line 151 of file Fixed16.hxx.
Comparison operator.
Definition at line 157 of file Fixed16.hxx.
|
inline |
Definition at line 225 of file Fixed16.hxx.
|
inline |
Definition at line 247 of file Fixed16.hxx.
|
inlineprivate |
Translates the current value to a signed fixed-point 32-bit integer.
Definition at line 298 of file Fixed16.hxx.
|
inline |
Turns the value into a comparison key.
Definition at line 291 of file Fixed16.hxx.
|
inline |
Definition at line 232 of file Fixed16.hxx.
|
private |
Definition at line 323 of file Fixed16.hxx.
|
private |
Definition at line 322 of file Fixed16.hxx.