C-XSC - A C++ Class Library for Extended Scientific Computing 2.5.4
cxsc::real Class Reference

The Scalar Type real. More...

#include <real.hpp>

Collaboration diagram for cxsc::real:
Collaboration graph

Public Member Functions

 real (const double &a) noexcept
 Constructor of class real.
 
 real (const float &a) noexcept
 Constructor of class real.
 
 real (const int a) noexcept
 Constructor of class real.
 
 real (const l_real &) noexcept
 Constructor of class real.
 
 real (const long a) noexcept
 Constructor of class real.
 
INLINE real (const rmatrix &) noexcept
 Constructor of class real.
 
INLINE real (const rmatrix_slice &) noexcept
 Constructor of class real.
 
INLINE real (const rvector &) noexcept
 Constructor of class real.
 
INLINE real (const rvector_slice &) noexcept
 Constructor of class real.
 
 real (void) noexcept
 Constructor of class real.
 

Friends

double _double (const real &a) noexcept
 Typecast to convert a real value into a double value.
 
real _real (const double &a) noexcept
 Deprecated typecast, which only exist for the reason of compatibility with older versions of C-XSC.
 
INLINE real _real (const rmatrix &) noexcept
 Deprecated typecast, which only exist for the reason of compatibility with older versions of C-XSC.
 
INLINE real _real (const rmatrix_slice &) noexcept
 Deprecated typecast, which only exist for the reason of compatibility with older versions of C-XSC.
 
INLINE real _real (const rvector &) noexcept
 Deprecated typecast, which only exist for the reason of compatibility with older versions of C-XSC.
 
INLINE real _real (const rvector_slice &) noexcept
 Deprecated typecast, which only exist for the reason of compatibility with older versions of C-XSC.
 
real abs (const real &a) noexcept
 The absolute value of a real value.
 
real adddown (const real &, const real &)
 Addition of two real values and rounding the result downwards.
 
real addup (const real &, const real &)
 Addition of two real values and rounding the result upwards.
 
real comp (const real &, a_intg)
 Composes an IEEE floating point value out of an given mantissa and exponent.
 
real divdown (const real &, const real &)
 Division of two real values and rounding the result downwards.
 
real divup (const real &, const real &)
 Division of two real values and rounding the result upwards.
 
a_intg expo (const real &) noexcept
 The exponent of a real value.
 
real mant (const real &) noexcept
 The mantissa of a real value.
 
real multdown (const real &, const real &)
 Multiplication of two real values and rounding the result downwards.
 
real multup (const real &, const real &)
 Multiplication of two real values and rounding the result upwards.
 
bool operator! (const real &a) noexcept
 Implementation of standard negation operation.
 
bool operator!= (const double &a, const real &b) noexcept
 Implementation of standard negated equality operation.
 
bool operator!= (const float &a, const real &b) noexcept
 Implementation of standard negated equality operation.
 
bool operator!= (const int &a, const real &b) noexcept
 Implementation of standard negated equality operation.
 
bool operator!= (const long &a, const real &b) noexcept
 Implementation of standard negated equality operation.
 
bool operator!= (const real &a, const double &b) noexcept
 Implementation of standard negated equality operation.
 
bool operator!= (const real &a, const float &b) noexcept
 Implementation of standard negated equality operation.
 
bool operator!= (const real &a, const int &b) noexcept
 Implementation of standard negated equality operation.
 
bool operator!= (const real &a, const long &b) noexcept
 Implementation of standard negated equality operation.
 
bool operator!= (const real &a, const real &b) noexcept
 Implementation of standard negated equality operation.
 
real operator* (const real &, const real &) noexcept
 Implementation of standard algebraic multiplication operation.
 
realoperator*= (real &, const real &) noexcept
 Implementation of standard algebraic multiplication and allocation operation.
 
real operator+ (const real &) noexcept
 Implementation of standard algebraic positive sign operation.
 
real operator+ (const real &, const real &) noexcept
 Implementation of standard algebraic addition operation.
 
realoperator+= (real &, const real &) noexcept
 Implementation of standard algebraic addition and allocation operation.
 
real operator- (const real &) noexcept
 Implementation of standard algebraic negative sign operation.
 
real operator- (const real &, const real &) noexcept
 Implementation of standard algebraic subtraction operation.
 
realoperator-= (real &, const real &) noexcept
 Implementation of standard algebraic subtraction and allocation operation.
 
real operator/ (const real &, const real &) noexcept
 Implementation of standard algebraic division operation.
 
realoperator/= (real &, const real &) noexcept
 Implementation of standard algebraic division and allocation operation.
 
bool operator< (const real &a, const real &b) noexcept
 Implementation of standard less-than operation.
 
std::ostream & operator<< (std::ostream &o, const real &a)
 Implementation of standard output method.
 
std::string & operator<< (std::string &s, const real &a)
 Implementation of standard output method.
 
bool operator<= (const real &a, const real &b) noexcept
 Implementation of standard less-or-equal-than operation.
 
bool operator== (const double &a, const real &b) noexcept
 Implementation of standard equality operation.
 
bool operator== (const float &a, const real &b) noexcept
 Implementation of standard equality operation.
 
bool operator== (const int &a, const real &b) noexcept
 Implementation of standard equality operation.
 
bool operator== (const long &a, const real &b) noexcept
 Implementation of standard equality operation.
 
bool operator== (const real &a, const double &b) noexcept
 Implementation of standard equality operation.
 
bool operator== (const real &a, const float &b) noexcept
 Implementation of standard equality operation.
 
bool operator== (const real &a, const int &b) noexcept
 Implementation of standard equality operation.
 
bool operator== (const real &a, const long &b) noexcept
 Implementation of standard equality operation.
 
bool operator== (const real &a, const real &b) noexcept
 Implementation of standard equality operation.
 
bool operator> (const real &a, const real &b) noexcept
 Implementation of standard greater-than operation.
 
bool operator>= (const real &a, const real &b) noexcept
 Implementation of standard greater-or-equal-than operation.
 
void operator>> (const char *a, real &b)
 Implementation of standard output method.
 
void operator>> (const std::string &, real &)
 Implementation of standard input method.
 
std::istream & operator>> (std::istream &s, real &a)
 Implementation of standard input method.
 
std::string & operator>> (std::string &str, real &a)
 Implementation of standard input method.
 
real pred (const real &) noexcept
 The predecessor of a real value.
 
int sign (const real &) noexcept
 The sign of a real value.
 
real subdown (const real &, const real &)
 Subtraction of two real values and rounding the result downwards.
 
real subup (const real &, const real &)
 Subtraction of two real values and rounding the result upwards.
 
real succ (const real &) noexcept
 The successor of a real value.
 

Detailed Description

The Scalar Type real.

The arithmetic of C-XSC is based on the IEEE standard for binary floating-point arithmetic. Data of the type real consist of all floating-point numbers and special values specified by the standard for floating-point numbers of double mantissa length. Therefore, a number of the type real is a 64-bit value, and the base $ b $ of the floating-point system $ R = R(b , l , e_min, e_max)\mbox{ is }2 $.

The C-XSC data type real differs only in some special aspects such as error handling from the C type double if used on a IEEE standard conforming arithmetic. If the C compiler on the host computer is not standard conforming, the data type real uses its own IEEE software arithmetic. Hence, the introduction of a new data type is necessary for the portability of C-XSC.

Structure

A sketch of the real floating-point data format is given in the figure below.

The real Floating-Point Format

The most significant bit is the sign bit, denoted by $ s $ . If it is one, the non-zero floating-point number is negative. Otherwise the floating-point number is positive.

The remaining 63 bits of the floating-point numbr are subdivided as follows:

Mantissa

The mantissa length $ l $ of a real value is 53 bits. Bit 53 is not explicitly stored. Its value depends upon the normalization or denormalization of the floating-point number represented. With this mantissa length $ l $, decimal numbers with a maximum of 15 fractional digits can be represented with high accuracy. Since a binary floating-point format is used, it is impossible to store all decimal numbers exactly. For example, the decimal number 0.6 is not exactly representable as a binary floating-point number. However, we can read decimal constants with controlled rounding into a variable of the type real.

Exponent

The exponent $ e $ of the floating-point number is stored in a field of 11 bit width using a biased notation. A value of 1023 is subtracted from the stored value to get the actual exponent value. This yields $ e_{min} = -1022 $ and $ e_{max} = 1023 $ . Converted to the decimal system, this yields $ -308 \le e \le 308 $ .

Definition at line 113 of file real.hpp.

Friends And Related Symbol Documentation

◆ _real [1/4]

INLINE real _real ( const rmatrix & )
friend

Deprecated typecast, which only exist for the reason of compatibility with older versions of C-XSC.

Deprecated
use standard contructors for typecasting
See also
cxsc::real::real(const rmatrix &)

◆ _real [2/4]

INLINE real _real ( const rmatrix_slice & )
friend

Deprecated typecast, which only exist for the reason of compatibility with older versions of C-XSC.

Deprecated
use standard contructors for typecasting
See also
cxsc::real::real(const rmatrix_slice &)

◆ _real [3/4]

INLINE real _real ( const rvector & )
friend

Deprecated typecast, which only exist for the reason of compatibility with older versions of C-XSC.

Deprecated
use standard contructors for typecasting
See also
cxsc::real::real(const rvector &)

◆ _real [4/4]

INLINE real _real ( const rvector_slice & )
friend

Deprecated typecast, which only exist for the reason of compatibility with older versions of C-XSC.

Deprecated
use standard contructors for typecasting
See also
cxsc::real::real(const rvector_slice &)

The documentation for this class was generated from the following files: