C-XSC - A C++ Class Library for Extended Scientific Computing 2.5.4
real.cpp
1/*
2** CXSC is a C++ library for eXtended Scientific Computing (V 2.5.4)
3**
4** Copyright (C) 1990-2000 Institut fuer Angewandte Mathematik,
5** Universitaet Karlsruhe, Germany
6** (C) 2000-2014 Wiss. Rechnen/Softwaretechnologie
7** Universitaet Wuppertal, Germany
8**
9** This library is free software; you can redistribute it and/or
10** modify it under the terms of the GNU Library General Public
11** License as published by the Free Software Foundation; either
12** version 2 of the License, or (at your option) any later version.
13**
14** This library is distributed in the hope that it will be useful,
15** but WITHOUT ANY WARRANTY; without even the implied warranty of
16** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17** Library General Public License for more details.
18**
19** You should have received a copy of the GNU Library General Public
20** License along with this library; if not, write to the Free
21** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22*/
23
24/* CVS $Id: real.cpp,v 1.28 2014/01/30 17:23:48 cxsc Exp $ */
25
26#include "real.hpp"
27#include "ioflags.hpp"
28
29namespace cxsc {
30
31//----------------------------------------------------------------------------
32// MakeHexReal - erstellt aus den binaer angegebenen Einzelteilen einer
33// IEEE 64-bit Gleitkommazahl eine solche, hierbei ist
34// sign Flag 'zu erzeugener real ist negativ'
35// expo Exponent (11 Bit 0x000 - 0x7FF)
36// manthigh obere 20 Bit der Mantisse (Bit 32 - 53)
37// mantlow untere 32 Bit der Mantisse (Bit 0 - 31)
38//
39// - die Mantisse ist normalisiert dargestellt, d.h.
40// implizit wird noch ein Bit 1 als Vorkommastelle
41// vorangestellt.
42// Eine Ausnahme bilden die Zahlen mit Exponent = 0,
43// oder Exponent = 0x7FF (alle Exponentenbits = 1)
44//
52const real& MakeHexReal(int sign, unsigned int expo, a_btyp manthigh, a_btyp mantlow)
53{
54 static real a;
55 ((a_btyp*)&a)[LOWREAL] = mantlow,
56 ((a_btyp*)&a)[HIGHREAL] = manthigh & 0xFFFFFL,
57 ((a_btyp*)&a)[HIGHREAL] |= ((a_btyp) (expo & 0x7FF)) << 20,
58 ((a_btyp*)&a)[HIGHREAL] |= (sign ? 0x80000000L : 0x00000000);
59 return a;
60}
61
62const real MinReal = MakeHexReal(0, 0x001, 0x00000L, 0x00000000L);
63const real minreal = MakeHexReal(0, 0x000, 0x00000L, 0x00000001L);
64// Blomquist, 26.09.02; minreal = smallest positive real number.
65const real MaxReal = MakeHexReal(0, 0x7FE, 0xFFFFFL, 0xFFFFFFFFL);
66const real Infinity = MakeHexReal(0, 0x7FF, 0x00000L, 0x00000000L);
67const real SignalingNaN = MakeHexReal(1, 0x7FF, 0x80000L, 0x00000000L);
68const real QuietNaN = MakeHexReal(0, 0x7FF, 0x00000L, 0x00000001L);
69const real Epsilon = power(2,-53);
70const real Factor = power(2, 27) + 1;
71
72
73// The following constants are roundet to the nearest machine nunmber:
74
75const real Pi_real = 7074237752028440.0 / 2251799813685248.0; // Pi
76const real Pi2_real = 7074237752028440.0/1125899906842624.0; // 2*Pi
77const real Pi3_real = 5305678314021330.0/562949953421312.0; // 3*Pi
78const real Pid2_real = 7074237752028440.0/4503599627370496.0; // Pi/2
79const real Pid3_real = 4716158501352294.0/4503599627370496.0; // Pi/3
80const real Pid4_real = 7074237752028440.0/9007199254740992.0; // Pi/4
81const real Pir_real = 5734161139222659.0/18014398509481984.0; // 1/Pi
82const real Pi2r_real = 5734161139222659.0/36028797018963968.0; // 1/(2*Pi)
83const real Pip2_real = 5556093337880030.0/562949953421312.0; // Pi^2
84const real SqrtPi_real = 7982422502469483.0/4503599627370496.0;// sqrt(Pi)
85const real Sqrt2Pi_real = 5644425081792262.0/2251799813685248.0; // sqrt(2Pi)
86const real SqrtPir_real = 5081767996463981.0/9007199254740992.0; // 1/sqrt(Pi)
87const real Sqrt2Pir_real = 7186705221432913.0/18014398509481984.0; // 1/sqrt(2Pi)
88const real Sqrt2_real = 6369051672525773.0/4503599627370496.0; // sqrt(2)
89const real Sqrt5_real = 5035177455121576.0 / 2251799813685248.0; // sqrt(5)
90const real Sqrt7_real = 5957702309312746.0 / 2251799813685248.0; // sqrt(7)
91const real Sqrt2r_real = 6369051672525773.0/9007199254740992.0;// 1/sqrt(2)
92const real Sqrt3_real = 7800463371553962.0/4503599627370496.0; // sqrt(3)
93const real Sqrt3d2_real = 7800463371553962.0/9007199254740992.0; // sqrt(3)/2
94const real Sqrt3r_real = 5200308914369308.0/9007199254740992.0;// 1/sqrt(3)
95const real Ln2_real = 6243314768165359.0 / 9007199254740992.0; // ln(2)
96const real Ln2r_real = 6497320848556798.0 / 4503599627370496.0; // 1/ln(2)
97const real Ln10_real = 5184960683398422.0 / 2251799813685248.0; // ln(10)
98const real Ln10r_real = 7823553867474190.0/18014398509481984.0; // 1/ln(10)
99const real LnPi_real = 5155405087351229.0 / 4503599627370496.0; // ln(Pi)
100const real Ln2Pi_real = 8277062471433909.0/4503599627370496.0; // ln(2Pi)
101const real E_real = 6121026514868073.0 / 2251799813685248.0; // e
102const real Er_real = 6627126856707896.0 / 18014398509481984.0; // 1/e
103const real Ep2_real = 8319337573440942.0 / 1125899906842624.0; // e^2
104const real Ep2r_real = 4875967449235916.0/36028797018963968.0; // 1/e^2
105const real EpPi_real = 6513525919879994.0/281474976710656.0; // e^(Pi)
106const real Ep2Pi_real = 4710234414611993.0/8796093022208.0; // e^(2Pi)
107const real EpPid2_real = 5416116035097439.0/1125899906842624.0; // e^(Pi/2)
108const real EpPid4_real = 4938827609611434.0/2251799813685248.0; // e^(Pi/4)
109
110} // namespace cxsc
The Scalar Type real.
Definition real.hpp:114
The namespace cxsc, providing all functionality of the class library C-XSC.
Definition cdot.cpp:29
const real EpPid4_real
Constant for rounded to the nearest machine number.
Definition real.cpp:108
const real Er_real
Constant for rounded to the nearest machine number.
Definition real.cpp:102
const real MinReal
Smallest normalized representable floating-point number.
Definition real.cpp:62
const real Sqrt3r_real
Constant for rounded to the nearest machine number.
Definition real.cpp:94
const real Sqrt2_real
Constant for rounded to the nearest machine number.
Definition real.cpp:88
cinterval power(const cinterval &z, int n) noexcept
Calculates .
Definition cimath.cpp:1941
const real Ln10_real
Constant for rounded to the nearest machine number.
Definition real.cpp:97
const real Sqrt7_real
Constant for rounded to the nearest machine number.
Definition real.cpp:90
const real MaxReal
Greatest representable floating-point number.
Definition real.cpp:65
const real SqrtPi_real
Constant for rounded to the nearest machine number.
Definition real.cpp:84
const real Pid4_real
Constant for rounded to the nearest machine number.
Definition real.cpp:80
const real Ln2_real
Constant for rounded to the nearest machine number.
Definition real.cpp:95
const real SqrtPir_real
Constant for rounded to the nearest machine number.
Definition real.cpp:86
const real Pip2_real
Constant for rounded to the nearest machine number.
Definition real.cpp:83
const real Sqrt2r_real
Constant for rounded to the nearest machine number.
Definition real.cpp:91
const real minreal
Smallest positive denormalized representable floating-point number.
Definition real.cpp:63
const real QuietNaN
Representation of Not-a-Number in floating-point format.
Definition real.cpp:68
const real E_real
Constant for rounded to the nearest machine number.
Definition real.cpp:101
const real SignalingNaN
Not defined result in floating-point format.
Definition real.cpp:67
const real Sqrt2Pi_real
Constant for rounded to the nearest machine number.
Definition real.cpp:85
const real Ln2r_real
Constant for rounded to the nearest machine number.
Definition real.cpp:96
const real Epsilon
Machine epsilon.
Definition real.cpp:69
const real EpPi_real
Constant for rounded to the nearest machine number.
Definition real.cpp:105
const real Pir_real
Constant for rounded to the nearest machine number.
Definition real.cpp:81
const real & MakeHexReal(int sign, unsigned int expo, a_btyp manthigh, a_btyp mantlow)
Produces an IEEE 64-bit floating-point number from given binary coded parts of an IEEE 64-bit floatin...
Definition real.cpp:52
const real Ep2_real
Constant for rounded to the nearest machine number.
Definition real.cpp:103
const real Pi3_real
Constant for rounded to the nearest machine number.
Definition real.cpp:77
const real Pid3_real
Constant for rounded to the nearest machine number.
Definition real.cpp:79
const real Infinity
Representation of positive infinity in floating-point format.
Definition real.cpp:66
const real LnPi_real
Constant for rounded to the nearest machine number.
Definition real.cpp:99
const real Sqrt5_real
Constant for rounded to the nearest machine number.
Definition real.cpp:89
const real Sqrt3_real
Constant for rounded to the nearest machine number.
Definition real.cpp:92
const real Ln2Pi_real
Constant for rounded to the nearest machine number.
Definition real.cpp:100
const real Pid2_real
Constant for rounded to the nearest machine number.
Definition real.cpp:78
const real Pi2_real
Constant for rounded to the nearest machine number.
Definition real.cpp:76
const real EpPid2_real
Constant for rounded to the nearest machine number.
Definition real.cpp:107
const real Pi2r_real
Constant for rounded to the nearest machine number.
Definition real.cpp:82
const real Sqrt2Pir_real
Constant for rounded to the nearest machine number.
Definition real.cpp:87
const real Pi_real
Constant for rounded to the nearest machine number.
Definition real.cpp:75
const real Sqrt3d2_real
Constant for rounded to the nearest machine number.
Definition real.cpp:93
const real Ep2r_real
Constant for rounded to the nearest machine number.
Definition real.cpp:104
const real Ln10r_real
Constant for rounded to the nearest machine number.
Definition real.cpp:98
const real Ep2Pi_real
Constant for rounded to the nearest machine number.
Definition real.cpp:106