RTI Connext TSS C++ API  Version 4.1.0 EAR
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
FACE::Fixed Class Reference

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.
Fixedoperator= (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)

Constructs a fixed-point number by converting from another representation.

Parameters:
valthe value to convert from
 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 round function rounds away from values halfway or more the to the next absolute value for the new scale. If the value currently has fewer or equal digits on the right relative to the new scale, both functions return the value unmodified. The truncate function always truncates the value towards zero. For example:

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.

Fixedoperator++ ()
 Prefix increment.
Fixed operator++ (int)
 Postfix increment.
Fixedoperator-- ()
 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:

  • one with _digits=d1 and _scale=s1 (fixed<d1, s1>)
  • another with _digits=d2 and _scale=s2 (fixed<d2, s2>). (s_inf denotes an arbitrary number of decimal places.)
Operation Result (fixed<d, s>)
+ fixed<max(d1-s1,d2-s2) + max(s1,s2) + 1, max(s1,s2)>
- fixed<max(d1-s1,d2-s2) + max(s1,s2) + 1, max(s1,s2)>
* fixed<d1+d2, s1+s2>
/ fixed<(d1-s1+s2) + s_inf, s_inf>
remainder fixed<max(s1,s2), max(s1,s2)>

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.

Fixedoperator+= (const Fixed &rhs)
 Calculates the in-place sum of two fixed-point numbers.
Fixedoperator-= (const Fixed &rhs)
 Calculates the in-place difference of two fixed-point numbers.
Fixedoperator*= (const Fixed &rhs)
 Calculates the in-place product of two fixed-point numbers.
Fixedoperator/= (const Fixed &rhs)
 Calculates the in-place quotient of two fixed-point numbers.
Fixedoperator% (const Fixed &rhs)
 Calculates the remainder after division of two fixed-point numbers.
Comparison Operations

Performs comparisons of fixed-point numbers.

Parameters:
rhsthe right-hand side of the comparison.
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).

Detailed Description

Class representing an IDL fixed type.


Constructor & Destructor Documentation

FACE::Fixed::Fixed ( FACE::UnsignedLong  digits,
FACE::UnsignedLong  scale 
)

Constructs a fixed point number with a specified digits and scale.

Parameters:
digitsthe total number of digits
scalethe 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.

FACE::Fixed::Fixed ( const FACE::Char *  val)
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.


Member Function Documentation

Fixed& FACE::Fixed::operator= ( const Fixed fx)

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.

Fixed& FACE::Fixed::operator+= ( const Fixed rhs)

Calculates the in-place sum of two fixed-point numbers.

Fixed& FACE::Fixed::operator-= ( const Fixed rhs)

Calculates the in-place difference of two fixed-point numbers.

Fixed& FACE::Fixed::operator*= ( const Fixed rhs)

Calculates the in-place product of two fixed-point numbers.

Fixed& FACE::Fixed::operator/= ( const Fixed rhs)

Calculates the in-place quotient of two fixed-point numbers.

Fixed& FACE::Fixed::operator% ( const Fixed rhs)

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.


Field Documentation

const FACE::Short FACE::Fixed::DIGITS_MAX = (FACE::Short)31
static

The maximum number of digits in a fixed-point number (enforced by IDL).


RTI Connext TSS C++ API Version 4.1.0 EAR Copyright © Thu Oct 9 2025 Real-Time Innovations, Inc