@@ -22,7 +22,7 @@ namespace sw {
22
22
void Progression (double v) {
23
23
using namespace sw ::universal;
24
24
25
- auto oldPrec = std::cout.precision ();
25
+ auto defaultPrecision = std::cout.precision ();
26
26
float f{ float (v) };
27
27
std::cout << std::setprecision (7 );
28
28
std::cout << to_binary (f, true ) << " : " << f << ' \n ' ;
@@ -34,7 +34,7 @@ namespace sw {
34
34
dd a{ v };
35
35
std::cout << std::setprecision (35 );
36
36
std::cout << to_binary (a, true ) << " : " << a << ' \n ' ;
37
- std::cout << std::setprecision (oldPrec );
37
+ std::cout << std::setprecision (defaultPrecision );
38
38
}
39
39
40
40
void dd_binary (dd const & v) {
82
82
using namespace sw ::universal;
83
83
84
84
std::string test_suite = " double-double (dd) experiments" ;
85
+ bool reportTestCases = true ;
85
86
int nrOfFailedTestCases = 0 ;
86
87
87
- auto oldPrec = std::cout.precision ();
88
+ ReportTestSuiteHeader (test_suite, reportTestCases);
89
+
90
+ auto defaultPrecision = std::cout.precision ();
91
+
92
+ std::cout << " + ---------- - unevaluated pairs------------ +\n " ;
93
+ {
94
+ // what is the value that adds a delta one below the least significant fraction bit of the high double?
95
+ // dd = high + lo
96
+ // = 1*2^0 + 1*2^-53
97
+ // = 1.0e00 + 1.0elog10(2^-53)
98
+ double high{ std::pow (2.0 , 0.0 ) };
99
+ ReportValue (high, " 2^0" );
100
+ double low{ std::pow (2.0 , -53.0 ) };
101
+ ReportValue (low, " 2^-53" );
102
+ std::cout << std::log10 (low) << ' \n ' ;
103
+ double exponent = -std::ceil (std::abs (std::log10 (low)));
104
+ std::cout << " exponent : " << exponent << ' \n ' ;
105
+
106
+ std::cout << std::setprecision (32 );
107
+ for (int i = 0 ; i < 54 ; ++i) {
108
+ low = (std::pow (2.0 , -53.0 - double (i)));
109
+ dd a (high, low);
110
+ std::cout << a << ' \n ' ;
111
+ }
112
+ std::cout << std::setprecision (defaultPrecision);
113
+ }
114
+
115
+ return 0 ;
88
116
89
117
std::cout << " Smallest normal number progressions\n " ;
90
118
{
@@ -144,7 +172,7 @@ try {
144
172
145
173
}
146
174
147
- std::cout << " +--------- doubledouble subnormal behavior --------+\n " ;
175
+ std::cout << " +--------- double-double subnormal behavior --------+\n " ;
148
176
{
149
177
constexpr double smallestNormal = std::numeric_limits<double >::min ();
150
178
ReportValue (smallestNormal, " smallest normal" );
@@ -183,7 +211,7 @@ try {
183
211
std::cout << " to_string(precision=4) format : " << a.to_string (4 ) << ' \n ' ;
184
212
}
185
213
186
- std::cout << std::setprecision (oldPrec );
214
+ std::cout << std::setprecision (defaultPrecision );
187
215
188
216
ReportTestSuiteResults (test_suite, nrOfFailedTestCases);
189
217
return (nrOfFailedTestCases > 0 ? EXIT_FAILURE : EXIT_SUCCESS);
0 commit comments