[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 29808d8 5/5: Resolve a marked defect [390]
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 29808d8 5/5: Resolve a marked defect [390] |
Date: |
Sun, 23 Apr 2017 15:37:32 -0400 (EDT) |
branch: master
commit 29808d8e6539b9790a7fbb091b7a9ca97b70c7e3
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Resolve a marked defect [390]
---
value_cast_test.cpp | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/value_cast_test.cpp b/value_cast_test.cpp
index 3bebc75..5c29de1 100644
--- a/value_cast_test.cpp
+++ b/value_cast_test.cpp
@@ -368,12 +368,25 @@ int extra_tests0()
double small = std::scalbn
(1.0
,std::numeric_limits<double>::min_exponent
-// TODO ?? Why doesn't this work with '- 1' appended?
-// ,static_cast<double>(std::numeric_limits<double>::min_exponent - 1)
);
BOOST_TEST_EQUAL( small, value_cast<double>(value_cast<std::string>(
small)));
BOOST_TEST_EQUAL(-small,
value_cast<double>(value_cast<std::string>(-small)));
+ // Of course, the minimum normalized power of two is this:
+ double tiny = std::scalbn
+ (1.0
+ ,std::numeric_limits<double>::min_exponent - 1
+ );
+ BOOST_TEST_EQUAL(0x1p-1022, tiny);
+ // which converts to this:
+ BOOST_TEST_EQUAL(0x0.fffffffffffffp-1022,
value_cast<double>(value_cast<std::string>(tiny)));
+ // which is the largest denormal.
+ //
+ // The round trip works for the values tested earlier only by
+ // accident: 17 digits are required for a binary64 round trip,
+ // but value_cast returns no more than 16 because the 17th is
+ // not known to be accurate.
+
return 0;
}