|
| FixedPoint ()=default |
| Default constructor, implicitly initialized to zero.
|
|
template<typename INT2 , typename std::enable_if< std::is_integral< INT2 >::value, int >::type = 0> |
| FixedPoint (INT2 i) |
| Constructor.
|
|
| FixedPoint (int_t i, bool raw) |
| Constructor.
|
|
FixedPoint | abs () const |
| Get the absolute value.
|
|
virtual ts::UString | description () const override |
| Get a textual description of the values of that type.
|
|
bool | divOverflow (const FixedPoint &x) const |
| Check if this fixed-point number generates an overflow when divided by another fixed-point.
|
|
virtual bool | fromString (const UString &str, UChar separator=COMMA, UChar decimal_dot=FULL_STOP) override |
| Parse a string and interpret it as a number.
|
|
virtual bool | inRange (int64_t min, int64_t max) const override |
| Check if the value of the number is within a range of integer value.
|
|
FixedPoint | max (const FixedPoint &x) const |
| Get the maximum value of two fixed-point numbers.
|
|
FixedPoint | min (const FixedPoint &x) const |
| Get the minimum value of two fixed-point numbers.
|
|
bool | mulOverflow (const FixedPoint &x) const |
| Check if this fixed-point number generates an overflow when multiplied by another fixed-point.
|
|
template<typename INT2 , typename std::enable_if< std::is_integral< INT2 >::value, int >::type = 0> |
bool | mulOverflow (INT2 x) const |
| Check if this fixed-point number generates an overflow when multiplied by an integer.
|
|
int_t | raw () const |
| Get the internal unconverted integer value.
|
|
virtual double | toDouble () const override |
| Conversion to double value.
|
|
int_t | toInt () const |
| Conversion to integral units.
|
|
virtual int64_t | toInt64 () const override |
| Conversion to a 64-bit signed integer value.
|
|
virtual UString | toString (size_t min_width=0, bool right_justified=true, UChar separator=COMMA, bool force_sign=false, size_t decimals=NPOS, bool force_decimals=false, UChar decimal_dot=FULL_STOP, UChar pad=SPACE) const override |
| Convert the number to a string object.
|
|
template<typename INT_T, const size_t PREC, typename std::enable_if< std::is_integral< INT_T >::value &&std::is_signed< INT_T >::value, int >::type = 0>
class ts::FixedPoint< INT_T, PREC, type >
Template representation of fixed-precision numbers.
A fixed-precision number is internally represented by an integer but with a different representation of a "unit". This concept is inspired by "fixed" types in Ada.
All arithmetic and comparison operators are defined between fixed-point type values and between a fixed-point value and an integer value, both directions.
- Template Parameters
-
INT_T | The underlying signed integer type. |
PREC | The decimal precision in digits. |
template<typename INT_T , const size_t PREC, typename std::enable_if< std::is_integral< INT_T >::value &&std::is_signed< INT_T >::value, int >::type = 0>
template<typename INT2 , typename std::enable_if< std::is_integral< INT2 >::value, int >::type = 0>
Constructor.
- Template Parameters
-
INT2 | Some other integer type (signed or unsigned). |
- Parameters
-
[in] | i | Initial value in integral number of units which is converted into the fixed-precision representation. |
template<typename INT_T , const size_t PREC, typename std::enable_if< std::is_integral< INT_T >::value &&std::is_signed< INT_T >::value, int >::type N>
Get a textual description of the values of that type.
This is typically used in help texts.
- Returns
- A textual description of the values of that type.
Implements ts::AbstractNumber.
template<typename INT_T , const size_t PREC, typename std::enable_if< std::is_integral< INT_T >::value &&std::is_signed< INT_T >::value, int >::type N>
bool ts::FixedPoint< INT_T, PREC, N >::inRange |
( |
int64_t |
min, |
|
|
int64_t |
max |
|
) |
| const |
|
overridevirtual |
Check if the value of the number is within a range of integer value.
- Parameters
-
[in] | min | Minimum integer value (inclusive). |
[in] | max | Maximum integer value (inclusive). |
- Returns
- True if this number is within the range min to max, inclusive.
Implements ts::AbstractNumber.
template<typename INT_T , const size_t PREC, typename std::enable_if< std::is_integral< INT_T >::value &&std::is_signed< INT_T >::value, int >::type N>
Parse a string and interpret it as a number.
The content of this object is updated from the parsed string.
- Parameters
-
[in] | str | A string to parse, representing this object. |
[in] | separator | Separator character for groups of thousands, a comma by default. |
[in] | decimal_dot | The decimal separator, a dot by default. |
- Returns
- True if the str is valid, false otherwise. In case of parsing error, the content of this object is undefined.
Implements ts::AbstractNumber.
template<typename INT_T , const size_t PREC, typename std::enable_if< std::is_integral< INT_T >::value &&std::is_signed< INT_T >::value, int >::type = 0>
template<typename INT2 , typename std::enable_if< std::is_integral< INT2 >::value, int >::type = 0>
Check if this fixed-point number generates an overflow when multiplied by an integer.
- Template Parameters
-
INT2 | Another integer type. |
- Parameters
-
[in] | x | An integer of type INT2. |
- Returns
- True if this fixed-point number generates an overflow when multiplied by x.