![]() |
TSDuck v3.46-4930
MPEG Transport Stream Toolkit
|
#include <tsFixedPoint.h>


Public Types | |
| using | int_t = INT_T |
Public Member Functions | |
| FixedPoint ()=default | |
| template<typename INT2> requires std::integral<INT2> | |
| FixedPoint (INT2 i) | |
| FixedPoint (int_t i, bool raw) | |
| FixedPoint | abs () const |
| virtual ts::UString | description () const override |
| bool | divOverflow (const FixedPoint &x) const |
| virtual bool | fromString (const UString &str, UChar separator=COMMA, UChar decimal_dot=FULL_STOP) override |
| virtual bool | inRange (int64_t min, int64_t max) const override |
| FixedPoint | max (const FixedPoint &x) const |
| FixedPoint | min (const FixedPoint &x) const |
| bool | mulOverflow (const FixedPoint &x) const |
| template<typename INT2> requires std::integral<INT2> | |
| bool | mulOverflow (INT2 x) const |
| int_t | raw () const |
| virtual double | toDouble () const override |
| int_t | toInt () const |
| virtual int64_t | toInt64 () const override |
| 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 |
Static Public Attributes | |
| static constexpr int_t | FACTOR = ts::static_power10<int_t, PRECISION>::value |
| static const AbstractNumber *const | INVALID |
| static const FixedPoint | MAX |
| static const FixedPoint | MIN |
| static constexpr size_t | PRECISION = PREC |
Static Protected Member Functions | |
| static void | Deformat (UString &str, UChar separator, UChar decimal_dot) |
| static void | Format (UString &str, size_t min_width, bool right_justified, UChar separator, bool add_plus_sign, size_t decimals, bool force_decimals, UChar decimal_dot, UChar pad) |
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.
| INT_T | The underlying signed integer type. |
| PREC | The decimal precision in digits. |
| using ts::FixedPoint< INT_T, PREC >::int_t = INT_T |
The underlying signed integer type.
|
default |
Default constructor, implicitly initialized to zero.
|
inline |
Constructor.
| INT2 | Some other integer type (signed or unsigned). |
| [in] | i | Initial value in integral number of units which is converted into the fixed-precision representation. |
|
inline |
Constructor.
| [in] | i | Initial value. Interpreted according to raw. |
| [in] | raw | If true, the value i is a raw underlying internal value, without conversion. If false, the value i is an integral number of units which is converted into the fixed-precision representation. |
|
overridevirtual |
Get a textual description of the values of that type. This is typically used in help texts.
Implements ts::AbstractNumber.
|
overridevirtual |
Check if the value of the number is within a range of integer value.
| [in] | min | Minimum integer value (inclusive). |
| [in] | max | Maximum integer value (inclusive). |
Implements ts::AbstractNumber.
|
overridevirtual |
Conversion to a 64-bit signed integer value.
Implements ts::AbstractNumber.
|
overridevirtual |
|
overridevirtual |
Parse a string and interpret it as a number. The content of this object is updated from the parsed string.
| [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. |
Implements ts::AbstractNumber.
|
overridevirtual |
Convert the number to a string object.
| [in] | min_width | Minimum width of the returned string. Padded with pad characters if larger than the number of characters in the formatted number. |
| [in] | right_justified | If true (the default), return a right-justified string. When false, return a left-justified string. Ignored if min_width is lower than the number of characters in the formatted number. |
| [in] | separator | Separator character for groups of thousands, a comma by default. CHAR_NULL means no separator. |
| [in] | force_sign | If true, force a '+' sign for positive values. |
| [in] | decimals | Precision to use after the decimal point. NPOS means default. |
| [in] | force_decimals | If true, with positive precision, force a decimal dot and the number of decimal digits of the precision. By default, skip non significant decimal digits. |
| [in] | decimal_dot | The decimal separator, a dot by default. |
| [in] | pad | The padding character to adjust the width. |
Implements ts::AbstractNumber.
|
inline |
Conversion to integral units.
|
inline |
Get the internal unconverted integer value.
|
inline |
Get the absolute value.
|
inline |
Get the maximum value of two fixed-point numbers.
| [in] | x | Another fixed-point number. |
|
inline |
Get the minimum value of two fixed-point numbers.
| [in] | x | Another fixed-point number. |
|
inline |
Check if this fixed-point number generates an overflow when multiplied by an integer.
| INT2 | Another integer type. |
| [in] | x | An integer of type INT2. |
|
inline |
Check if this fixed-point number generates an overflow when multiplied by another fixed-point.
| [in] | x | Another fixed-point number. |
|
inline |
Check if this fixed-point number generates an overflow when divided by another fixed-point.
| [in] | x | Another fixed-point. |
|
staticprotectedinherited |
Static common utility to format a string containing a number with or without decimal part.
| [in,out] | str | String to format. |
| [in] | min_width | Minimum width of the string. |
| [in] | right_justified | If true (the default), return a right-justified string. |
| [in] | separator | Separator character for groups of thousands. |
| [in] | add_plus_sign | If true, force a '+' sign before the number. |
| [in] | decimals | Precision to use after the decimal point. NPOS not allowed. |
| [in] | force_decimals | If true, force a decimal dot and the number of decimal digits. For integer types, use force_decimals == true and decimals == 0. |
| [in] | decimal_dot | The decimal separator. |
| [in] | pad | The padding character to adjust the width. |
|
staticprotectedinherited |
Static common utility to deformat a string containing a number.
| [in,out] | str | String to deformat. |
| [in] | separator | Separator character for groups of thousands. |
| [in] | decimal_dot | The decimal separator. |
|
staticconstexpr |
The precision of the fixed number type (number of decimal digits).
|
staticconstexpr |
The factor to convert between FixedPoint and int_t (10**PRECISION).
|
static |
The minimum representable value of this fixed-point type.
|
static |
The maximum representable value of this fixed-point type.
|
staticinherited |
Pointer to an invalid instance of AbstractNumber. Its toString() method always return an empty string.