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>

List of all members.

Public Member Functions

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

Friends

double _double (const real &a) throw ()
 Typecast to convert a real value into a double value.
real _real (const double &a) throw ()
 Deprecated typecast, which only exist for the reason of compatibility with older versions of C-XSC.
real _real (const rvector &) throw ()
 Deprecated typecast, which only exist for the reason of compatibility with older versions of C-XSC.
real _real (const rvector_slice &) throw ()
 Deprecated typecast, which only exist for the reason of compatibility with older versions of C-XSC.
real _real (const rmatrix &) throw ()
 Deprecated typecast, which only exist for the reason of compatibility with older versions of C-XSC.
real _real (const rmatrix_slice &) throw ()
 Deprecated typecast, which only exist for the reason of compatibility with older versions of C-XSC.
real abs (const real &a) throw ()
 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) throw ()
 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 &) throw ()
 The exponent of a real value.
real mant (const real &) throw ()
 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) throw ()
 Implementation of standard negation operation.
bool operator!= (const real &a, const real &b) throw ()
 Implementation of standard negated equality operation.
bool operator!= (const real &a, const int &b) throw ()
 Implementation of standard negated equality operation.
bool operator!= (const int &a, const real &b) throw ()
 Implementation of standard negated equality operation.
bool operator!= (const real &a, const long &b) throw ()
 Implementation of standard negated equality operation.
bool operator!= (const long &a, const real &b) throw ()
 Implementation of standard negated equality operation.
bool operator!= (const real &a, const float &b) throw ()
 Implementation of standard negated equality operation.
bool operator!= (const float &a, const real &b) throw ()
 Implementation of standard negated equality operation.
bool operator!= (const real &a, const double &b) throw ()
 Implementation of standard negated equality operation.
bool operator!= (const double &a, const real &b) throw ()
 Implementation of standard negated equality operation.
real operator* (const real &, const real &) throw ()
 Implementation of standard algebraic multiplication operation.
realoperator*= (real &, const real &) throw ()
 Implementation of standard algebraic multiplication and allocation operation.
real operator+ (const real &) throw ()
 Implementation of standard algebraic positive sign operation.
real operator+ (const real &, const real &) throw ()
 Implementation of standard algebraic addition operation.
realoperator+= (real &, const real &) throw ()
 Implementation of standard algebraic addition and allocation operation.
real operator- (const real &) throw ()
 Implementation of standard algebraic negative sign operation.
real operator- (const real &, const real &) throw ()
 Implementation of standard algebraic subtraction operation.
realoperator-= (real &, const real &) throw ()
 Implementation of standard algebraic subtraction and allocation operation.
real operator/ (const real &, const real &) throw ()
 Implementation of standard algebraic division operation.
realoperator/= (real &, const real &) throw ()
 Implementation of standard algebraic division and allocation operation.
bool operator< (const real &a, const real &b) throw ()
 Implementation of standard less-than operation.
std::ostream & operator<< (std::ostream &, const real &) throw ()
 Implementation of standard output method.
std::string & operator<< (std::string &, const real &) throw ()
 Implementation of standard output method.
bool operator<= (const real &a, const real &b) throw ()
 Implementation of standard less-or-equal-than operation.
bool operator== (const real &a, const real &b) throw ()
 Implementation of standard equality operation.
bool operator== (const real &a, const int &b) throw ()
 Implementation of standard equality operation.
bool operator== (const int &a, const real &b) throw ()
 Implementation of standard equality operation.
bool operator== (const real &a, const long &b) throw ()
 Implementation of standard equality operation.
bool operator== (const long &a, const real &b) throw ()
 Implementation of standard equality operation.
bool operator== (const real &a, const float &b) throw ()
 Implementation of standard equality operation.
bool operator== (const float &a, const real &b) throw ()
 Implementation of standard equality operation.
bool operator== (const real &a, const double &b) throw ()
 Implementation of standard equality operation.
bool operator== (const double &a, const real &b) throw ()
 Implementation of standard equality operation.
bool operator> (const real &a, const real &b) throw ()
 Implementation of standard greater-than operation.
bool operator>= (const real &a, const real &b) throw ()
 Implementation of standard greater-or-equal-than operation.
std::istream & operator>> (std::istream &, real &) throw ()
 Implementation of standard input method.
std::string & operator>> (std::string &, real &) throw ()
 Implementation of standard input method.
void operator>> (const char *, real &) throw ()
 Implementation of standard output method.
void operator>> (const std::string &, real &) throw ()
 Implementation of standard input method.
real pred (const real &) throw ()
 The predecessor of a real value.
int sign (const real &) throw ()
 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 &) throw ()
 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.

ieee_real_float_format.png
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 Function Documentation

real _real ( const rvector ) throw () [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 _real ( const rvector_slice ) throw () [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 &)
real _real ( const rmatrix ) throw () [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 _real ( const rmatrix_slice ) throw () [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 &)

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