changeset 205:91f52d537631 release

Merge with candidate 0.5.1.
author John Schneiderman <JohnMS@member.fsf.org>
date Mon, 15 Mar 2021 16:18:44 +0100
parents 66ddbc1762ae (current diff) b03cd24387d4 (diff)
children 64e426ec6b32
files
diffstat 4 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Mar 01 16:17:58 2021 +0100
+++ b/ChangeLog	Mon Mar 15 16:18:44 2021 +0100
@@ -17,6 +17,9 @@
 #**  You should have received a copy of the GNU Lesser General Public License***
 #**  along with this program. If not, see <http://www.gnu.org/licenses/>.    ***
 #*******************************************************************************
+2021-03-08 John Schneiderman <JohnMS_AT_member_DOT_fsf_DOT_org> 0.5.1
+	* Bug Fix: Failed to clear the floating-point exceptions prior to floating-point operations
+			resulted in valid floating-point operations failing when they should succeed.
 2021-02-27 John Schneiderman <JohnMS_AT_member_DOT_fsf_DOT_org> 0.5.0
 	* Feature: All currency codes supplied by the ISO.
 	* Feature: The money object swaperator is now noexcept.
--- a/src/external/pecunia/Money.cpp	Mon Mar 01 16:17:58 2021 +0100
+++ b/src/external/pecunia/Money.cpp	Mon Mar 15 16:18:44 2021 +0100
@@ -38,6 +38,8 @@
 
 #include <cassert>
 // Used for assert.
+#include <cfenv>
+using std::feclearexcept;
 #include <cstdlib>
 // Used for lldiv.
 #include <cmath>
@@ -714,6 +716,7 @@
 		minorUnitPrecisionFactor(this->iso4217Code_)
 			* static_cast<int32_t>(pow(10, extraFloatingPointPrecision))
 	};
+	feclearexcept(FE_ALL_EXCEPT);
 	const auto adjustedValue{verifiedFloatingPoint(value * unitRatio)};
 	*this *= static_cast<int64_t>(adjustedValue);
 	this->amount_ /= unitRatio;
@@ -839,6 +842,7 @@
 	default:
 		throw logic_error{"Incorrect multiplication verification result during division."};
 	};
+	feclearexcept(FE_ALL_EXCEPT);
 	const auto adjustedValue{
 		static_cast<UnitStorage>(
 			verifiedFloatingPoint(value * static_cast<FloatingPoint>(unitRatio))
--- a/src/external/pecunia/Rounders.cpp	Mon Mar 01 16:17:58 2021 +0100
+++ b/src/external/pecunia/Rounders.cpp	Mon Mar 15 16:18:44 2021 +0100
@@ -25,6 +25,8 @@
 
 #include <cassert>
 // Used for assert.
+#include <cfenv>
+using std::feclearexcept;
 #include <cmath>
 using std::abs;
 using std::ceil;
@@ -67,15 +69,18 @@
 	const FloatingPoint shiftOver{static_cast<FloatingPoint>(pow(10, digitsLeft))};
 	FloatingPoint whole;
 	const FloatingPoint fraction{modf(number, &whole)};
+	feclearexcept(FE_ALL_EXCEPT);
 	const FloatingPoint shiftedFraction{verifiedFloatingPoint(fraction * shiftOver)};
 	FloatingPoint roundPointWhole;
 	const FloatingPoint roundPoint{modf(shiftedFraction, &roundPointWhole)};
 	assert(abs(roundPoint) < 1.0 && "The rounding point must be less than one.");
+	feclearexcept(FE_ALL_EXCEPT);
 	const FloatingPoint shiftedRoundedFraction{
 		verifiedFloatingPoint(roundPointWhole + rounder(roundPoint, whole))
 	};
 	FloatingPoint roundedResult;
 	static_cast<void>(modf(shiftedRoundedFraction, &roundedResult));
+	feclearexcept(FE_ALL_EXCEPT);
 	const auto roundedNumber{verifiedFloatingPoint(whole + (roundedResult / shiftOver))};
 	return roundedNumber;
 }
--- a/src/internal/Adjustments.cpp	Mon Mar 01 16:17:58 2021 +0100
+++ b/src/internal/Adjustments.cpp	Mon Mar 15 16:18:44 2021 +0100
@@ -29,6 +29,8 @@
 
 #include <cassert>
 // using assert;
+#include <cfenv>
+using std::feclearexcept;
 #include <cmath>
 using std::abs;
 #include <stdexcept>
@@ -58,6 +60,7 @@
 		static_cast<uint8_t>(minorUnitDigits(code) + currencyPrecision + extraFloatingPointPrecision)
 	};
 	const int32_t ratio{minorUnitPrecisionFactor(code)};
+	feclearexcept(FE_ALL_EXCEPT);
 	const UnitStorage major{
 		static_cast<UnitStorage>(
 			verifiedFloatingPoint((rounder(value, totalDigits) * ratio) / ratio)
@@ -81,6 +84,7 @@
 		minorUnitPrecisionFactor(code)
 			* static_cast<int32_t>(pow(10, extraFloatingPointPrecision))
 	};
+	feclearexcept(FE_ALL_EXCEPT);
 	const UnitStorage adjustedValue{
 		static_cast<UnitStorage>(
 			verifiedFloatingPoint(rounder(value, totalDigits) * ratio)
@@ -100,6 +104,7 @@
 
 	if (isEqual(conversionFactor, 1.0, static_cast<uint8_t>(minorUnitDigits(fromCode) + precision)))
 		return from.amount();
+	feclearexcept(FE_ALL_EXCEPT);
 	const auto convertedAmount{
 		verifiedFloatingPoint(static_cast<FloatingPoint>(from.amount()) * conversionFactor)
 	};