|
| FloatingPoint ()=default |
| Default constructor, implicitly initialized to zero.
|
|
template<typename NUM_T , typename std::enable_if< std::is_arithmetic< NUM_T >::value, int >::type = 0> |
| FloatingPoint (NUM_T x) |
| Constructor from an integer or floating-point value.
|
|
FloatingPoint | 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 FloatingPoint &x) const |
| Check if this FloatingPoint number generates an overflow when divided by another FloatingPoint.
|
|
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.
|
|
FloatingPoint | max (const FloatingPoint &x) const |
| Get the maximum value of two fractions.
|
|
FloatingPoint | min (const FloatingPoint &x) const |
| Get the minimum value of two fractions.
|
|
bool | mulOverflow (const FloatingPoint &x) const |
| Check if this FloatingPoint number generates an overflow when multiplied by another FloatingPoint.
|
|
template<typename INT2 , typename std::enable_if< std::is_integral< INT2 >::value, int >::type = 0> |
bool | mulOverflow (INT2 x) const |
| Check if this FloatingPoint number generates an overflow when multiplied by an integer.
|
|
virtual double | toDouble () const override |
| Conversion to double value.
|
|
int_t | toInt () const |
| Conversion to integral value.
|
|
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 FLOAT_T, const size_t PREC = 6, typename std::enable_if< std::is_floating_point< FLOAT_T >::value, int >::type = 0>
class ts::FloatingPoint< FLOAT_T, PREC, type >
Encapsulation of a double floating-point as an AbstractNumber.
- Template Parameters
-
FLOAT_T | The underlying floating-point type. |
PREC | The number of decimal digits to display by default. This is a display attribute only, it does not alter the binary representation of floating-point values. The default is to display 6 digits. |
template<typename FLOAT_T , const size_t PREC = 6, typename std::enable_if< std::is_floating_point< FLOAT_T >::value, int >::type = 0>
template<typename NUM_T , typename std::enable_if< std::is_arithmetic< NUM_T >::value, int >::type = 0>
Constructor from an integer or floating-point value.
- Template Parameters
-
NUM_T | Some integer or floating-point type. |
- Parameters
-
template<typename FLOAT_T , const size_t PREC, typename std::enable_if< std::is_floating_point< FLOAT_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 FLOAT_T , const size_t PREC, typename std::enable_if< std::is_floating_point< FLOAT_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 FLOAT_T , const size_t PREC = 6, typename std::enable_if< std::is_floating_point< FLOAT_T >::value, int >::type = 0>
template<typename INT2 , typename std::enable_if< std::is_integral< INT2 >::value, int >::type = 0>
Check if this FloatingPoint number generates an overflow when multiplied by an integer.
The method is present for compliance with other AbstractNumber subclasses.
- Template Parameters
-
INT2 | Another integer type. |
- Parameters
-
[in] | x | An integer of type INT2. |
- Returns
- Always false. A better idea?
template<typename FLOAT_T , const size_t PREC = 6, typename std::enable_if< std::is_floating_point< FLOAT_T >::value, int >::type = 0>
The displayed precision of the floating-point type (number of decimal digits).
This is a display attribute only, it does not alter the binary representation of floating-point values.
template<typename FLOAT_T , const size_t PREC = 6, typename std::enable_if< std::is_floating_point< FLOAT_T >::value, int >::type = 0>
Precision of "equal" comparisons.
We cannot test equality between floating point values. Because of rounding issues, it does not make sense. Instead we check if the absolute value of their difference is lower than some very small value, this precision.