RTI Connext TSS C++ API
Version 4.1.0 EAR
|
Class representing an IDL fixed type. More...
#include <Fixed.hpp>
Public Member Functions | |||||||||||||
Fixed (FACE::UnsignedLong digits, FACE::UnsignedLong scale) | |||||||||||||
Constructs a fixed point number with a specified digits and scale. | |||||||||||||
Fixed (const Fixed &fx) | |||||||||||||
Copy constructor - creates a copy of a fixed type, maintaining its digits, scale, and value. | |||||||||||||
Fixed & | operator= (const Fixed &fx) | ||||||||||||
Assignment operator - assigns the digits, scale, and value of one fixed type to another. | |||||||||||||
~Fixed () | |||||||||||||
Destructor - performs any necessary implementation-specific cleanup. | |||||||||||||
Fixed | operator+ () const | ||||||||||||
Calculates the absolute value of a fixed-point number. | |||||||||||||
Fixed | operator- () const | ||||||||||||
Calculates the absolute value of a fixed-point number, multiplied by -1. | |||||||||||||
FACE::Boolean | operator! () const | ||||||||||||
Returns false if value is 0; true otherwise. | |||||||||||||
FACE::UnsignedShort | digits () const | ||||||||||||
Returns the smallest digits value that can hold the complete fixed-point value. | |||||||||||||
FACE::UnsignedShort | scale () const | ||||||||||||
Returns the smallest scale value that can hold the complete fixed-point value. | |||||||||||||
Constructors (Conversion) | |||||||||||||
Fixed (FACE::Short val=0) | |||||||||||||
Fixed (FACE::UnsignedShort val) | |||||||||||||
Fixed (FACE::Long val) | |||||||||||||
Fixed (FACE::UnsignedLong val) | |||||||||||||
Fixed (FACE::LongLong val) | |||||||||||||
Fixed (FACE::UnsignedLongLong val) | |||||||||||||
Fixed (FACE::Double val) | |||||||||||||
Fixed (FACE::LongDouble val) | |||||||||||||
Fixed (FACE::Float val) | |||||||||||||
Fixed (const FACE::Char *val) | |||||||||||||
Constructs a fixed-point number with a string representation of a fixed-point literal. | |||||||||||||
Conversions | |||||||||||||
operator FACE::LongLong () const | |||||||||||||
Converts a fixed-point number to an integer number. | |||||||||||||
operator FACE::LongDouble () const | |||||||||||||
Converts a fixed-point number to a floating-point number. | |||||||||||||
operator FACE::Char * () const | |||||||||||||
Converts a fixed-point number to a string representation of a fixed-point literal. | |||||||||||||
Precision Modifiers | |||||||||||||
Converts a fixed value to a new value with a specified scale. If the value currently has more digits on the right than the new scale, the f1: 0.1 Round with scale 0 => 0 Trunc with scale 0 => 0 f2: 0.05 Round with scale 1 => 0.1 Trunc with scale 1 => 0.0 f3: -0.005 Round with scale 1 => -0.01 Trunc with scale 1 => 0.00 If the specified scale would result in an invalid fixed-point number, the result is implementation-defined. | |||||||||||||
Fixed | round (FACE::UnsignedShort scale) const | ||||||||||||
Fixed | truncate (FACE::UnsignedShort scale) const | ||||||||||||
Arithmetic Operations (In-place) | |||||||||||||
Performs an arithmetic operation on a fixed-point number. If the magnitude of the fixed-point value does not fit, the result is implementation-defined. | |||||||||||||
Fixed & | operator++ () | ||||||||||||
Prefix increment. | |||||||||||||
Fixed | operator++ (int) | ||||||||||||
Postfix increment. | |||||||||||||
Fixed & | operator-- () | ||||||||||||
Prefix decrement. | |||||||||||||
Fixed | operator-- (int) | ||||||||||||
Postfix decrement. | |||||||||||||
Arithmetic Operations (Binary) | |||||||||||||
Performs an arithmetic operation on two fixed-point numbers. These functions calculate a result exactly using double precision arithmetic and truncating the result to fit into the smallest valid fixed-point number that can represent the result. The following table summarizes the type resulting from an operation on two fixed point numbers:
If the actual result is more than DIGITS_MAX significant digits, the result is retained as: fixed<d,s> => fixed<DIGITS_MAX, DIGITS_MAX-d+s>. Any of the three parameters may be equal (i.e. point to the same fixed-point number in memory); local temporary copies ensure the result is as expected. If the magnitude of the result does not fit in a valid fixed-point number, the result is implementation-defined. | |||||||||||||
Fixed & | operator+= (const Fixed &rhs) | ||||||||||||
Calculates the in-place sum of two fixed-point numbers. | |||||||||||||
Fixed & | operator-= (const Fixed &rhs) | ||||||||||||
Calculates the in-place difference of two fixed-point numbers. | |||||||||||||
Fixed & | operator*= (const Fixed &rhs) | ||||||||||||
Calculates the in-place product of two fixed-point numbers. | |||||||||||||
Fixed & | operator/= (const Fixed &rhs) | ||||||||||||
Calculates the in-place quotient of two fixed-point numbers. | |||||||||||||
Fixed & | operator% (const Fixed &rhs) | ||||||||||||
Calculates the remainder after division of two fixed-point numbers. | |||||||||||||
Comparison Operations | |||||||||||||
Performs comparisons of fixed-point numbers.
| |||||||||||||
FACE::Boolean | operator> (const Fixed &rhs) const | ||||||||||||
Returns 1 if lhs greater than rhs; 0 otherwise. | |||||||||||||
FACE::Boolean | operator< (const Fixed &rhs) const | ||||||||||||
Returns 1 if lhs less than rhs; 0 otherwise. | |||||||||||||
FACE::Boolean | operator>= (const Fixed &rhs) const | ||||||||||||
Returns 1 if lhs greater than or equal to rhs; 0 otherwise. | |||||||||||||
FACE::Boolean | operator<= (const Fixed &rhs) const | ||||||||||||
Returns 1 if lhs less than or equal to rhs; 0 otherwise. | |||||||||||||
FACE::Boolean | operator== (const Fixed &rhs) const | ||||||||||||
Returns 1 if lhs is equal to rhs; 0 otherwise. | |||||||||||||
FACE::Boolean | operator!= (const Fixed &rhs) const | ||||||||||||
Returns 1 if lhs is not equal to rhs; 0 otherwise. |
Static Public Attributes | |
static const FACE::Short | DIGITS_MAX = (FACE::Short)31 |
The maximum number of digits in a fixed-point number (enforced by IDL). |
Class representing an IDL fixed type.
FACE::Fixed::Fixed | ( | FACE::UnsignedLong | digits, |
FACE::UnsignedLong | scale | ||
) |
Constructs a fixed point number with a specified digits and scale.
digits | the total number of digits |
scale | the total number of significant fractional digits |
FACE::Fixed::Fixed | ( | const Fixed & | fx | ) |
Copy constructor - creates a copy of a fixed type, maintaining its digits, scale, and value.
FACE::Fixed::~Fixed | ( | ) |
Destructor - performs any necessary implementation-specific cleanup.
|
explicit |
Constructs a fixed-point number with a string representation of a fixed-point literal.
(see Constructors) A valid fixed-point literal string contains at least 1 and no more than DIGITS_MAX decimal digits, an optional decimal point, an optional leading +/-, and an optional trailing d/D. An invalid fixed-point literal string results in implementation-defined behavior.
Assignment operator - assigns the digits, scale, and value of one fixed type to another.
FACE::Fixed::operator FACE::LongLong | ( | ) | const |
Converts a fixed-point number to an integer number.
Digits to the right of the decimal point are truncated. If the magnitude of the fixed-point value does not fit, the result is implementation-defined.
FACE::Fixed::operator FACE::LongDouble | ( | ) | const |
Converts a fixed-point number to a floating-point number.
If the magnitude of the fixed-point value does not fit, the result is implementation-defined.
FACE::Fixed::operator FACE::Char * | ( | ) | const |
Converts a fixed-point number to a string representation of a fixed-point literal.
The string starts with a '-' if negative and nothing if positive, and always ends with a 'd'. Leading zeros are dropped, but trailing fractional zeros are preserved. For example, a fixed-point number with digits=4 and scale=2 with the value 1.1 is converted to "1.10d".) (See Constructors for more details on valid string representations of fixed point literals.)
Fixed& FACE::Fixed::operator++ | ( | ) |
Prefix increment.
Fixed FACE::Fixed::operator++ | ( | int | ) |
Postfix increment.
Fixed& FACE::Fixed::operator-- | ( | ) |
Prefix decrement.
Fixed FACE::Fixed::operator-- | ( | int | ) |
Postfix decrement.
Calculates the in-place sum of two fixed-point numbers.
Calculates the in-place difference of two fixed-point numbers.
Calculates the in-place product of two fixed-point numbers.
Calculates the in-place quotient of two fixed-point numbers.
Calculates the remainder after division of two fixed-point numbers.
FACE::Boolean FACE::Fixed::operator> | ( | const Fixed & | rhs | ) | const |
Returns 1 if lhs greater than rhs; 0 otherwise.
FACE::Boolean FACE::Fixed::operator< | ( | const Fixed & | rhs | ) | const |
Returns 1 if lhs less than rhs; 0 otherwise.
FACE::Boolean FACE::Fixed::operator>= | ( | const Fixed & | rhs | ) | const |
Returns 1 if lhs greater than or equal to rhs; 0 otherwise.
FACE::Boolean FACE::Fixed::operator<= | ( | const Fixed & | rhs | ) | const |
Returns 1 if lhs less than or equal to rhs; 0 otherwise.
FACE::Boolean FACE::Fixed::operator== | ( | const Fixed & | rhs | ) | const |
Returns 1 if lhs is equal to rhs; 0 otherwise.
FACE::Boolean FACE::Fixed::operator!= | ( | const Fixed & | rhs | ) | const |
Returns 1 if lhs is not equal to rhs; 0 otherwise.
Fixed FACE::Fixed::operator+ | ( | ) | const |
Calculates the absolute value of a fixed-point number.
Fixed FACE::Fixed::operator- | ( | ) | const |
Calculates the absolute value of a fixed-point number, multiplied by -1.
FACE::Boolean FACE::Fixed::operator! | ( | ) | const |
Returns false if value is 0; true otherwise.
FACE::UnsignedShort FACE::Fixed::digits | ( | ) | const |
Returns the smallest digits value that can hold the complete fixed-point value.
FACE::UnsignedShort FACE::Fixed::scale | ( | ) | const |
Returns the smallest scale value that can hold the complete fixed-point value.
|
static |
The maximum number of digits in a fixed-point number (enforced by IDL).