Skip to content

Commit 58500ba

Browse files
committed
refining numeric_limits for double-double
1 parent b122cb2 commit 58500ba

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

include/universal/number/dd/dd_impl.hpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ class dd {
313313
return *this;
314314
}
315315
constexpr dd& minpos() noexcept {
316-
hi = 1.0f;
316+
hi = std::numeric_limits<double>::min();
317317
lo = 0.0f;
318318
return *this;
319319
}
@@ -323,13 +323,13 @@ class dd {
323323
return *this;
324324
}
325325
constexpr dd& minneg() noexcept {
326-
hi = 1.0f;
326+
hi = -std::numeric_limits<double>::min();
327327
lo = 0.0f;
328328
return *this;
329329
}
330330
constexpr dd& maxneg() noexcept {
331-
hi = 1.0f;
332-
lo = 0.0f;
331+
hi = -1.7976931348623157e+308;
332+
lo = -1.9958403095347196e+292;
333333
return *this;
334334
}
335335

include/universal/number/dd/numeric_limits.hpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ class numeric_limits< sw::universal::dd > {
1818
return DoubleDouble(radix * (numeric_limits< double >::min() / numeric_limits< double >::epsilon()));
1919
}
2020
static constexpr DoubleDouble max() { // return maximum value
21-
//return DoubleDouble(sw::universal::SpecificValue::maxpos);
22-
return DoubleDouble(numeric_limits< double >::max());
21+
return DoubleDouble(sw::universal::SpecificValue::maxpos);
2322
}
2423
static constexpr DoubleDouble lowest() { // return most negative value
2524
//return DoubleDouble(sw::universal::SpecificValue::maxneg);

static/dd/api/api.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ try {
339339
}
340340
}
341341

342-
std::cout << "+--------- numeric_limits of doubledouble vs IEEE-754 --------+\n";
342+
std::cout << "+--------- numeric_limits of double-double vs IEEE-754 --------+\n";
343343
{
344344
std::cout << "dd(INFINITY): " << dd(INFINITY) << "\n";
345345
std::cout << "dd(-INFINITY): " << dd(-INFINITY) << "\n";
@@ -360,6 +360,14 @@ try {
360360
std::cout << "dd(std::numeric_limits<float>::signaling_NaN()).isnan(sw::universal::NAN_TYPE_SIGNALLING) : " << dd(std::numeric_limits<float>::signaling_NaN()).isnan(sw::universal::NAN_TYPE_SIGNALLING) << "\n";
361361
}
362362

363+
std::cout << "+---------- numeric traits of double-double ----------+\n";
364+
{
365+
numberTraits<dd>(std::cout);
366+
constexpr bool hasSubnormals = true;
367+
using Cfloat = cfloat<1 + 11 + 105, 11, uint32_t, hasSubnormals>;
368+
numberTraits<Cfloat>(std::cout);
369+
}
370+
363371
ReportTestSuiteResults(test_suite, nrOfFailedTestCases);
364372
return (nrOfFailedTestCases > 0 ? EXIT_FAILURE : EXIT_SUCCESS);
365373
}

0 commit comments

Comments
 (0)