[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 909aaca 1/5: Re-work around a MinGW-w64 gcc-7
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 909aaca 1/5: Re-work around a MinGW-w64 gcc-7.2.0 anomaly |
Date: |
Thu, 15 Mar 2018 14:14:26 -0400 (EDT) |
branch: master
commit 909aaca27c39712a44ff2f278b94ae41ee0ae1c3
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Re-work around a MinGW-w64 gcc-7.2.0 anomaly
Removing the call to std::floor() changed the behavior of
static_cast<int>(), causing another assertion to fire and preventing
a billion-dollar PDF from being generated.
---
ledger_base.cpp | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/ledger_base.cpp b/ledger_base.cpp
index 5814d6c..fecdba1 100644
--- a/ledger_base.cpp
+++ b/ledger_base.cpp
@@ -359,9 +359,11 @@ namespace
// it fails--apparently floor() gives the wrong answer, but trunc()
// and static_cast<int>() give the right answer for the test case
// described in the git commit message for 1c1bafa40. Obviously this
- // needs further work because the behavior in other cases is unknown.
+ // needs further work because the behavior in other cases is unknown,
+ // and adding a small quantity to a near-integer to force it to round
+ // "correctly" is surely bogus.
// LMI_ASSERT(power == std::floor(power));
- int z = static_cast<int>(power);
+ int z = static_cast<int>(0.1 + power);
// US names are used; UK names are different.
// Assume that numbers over 999 quintillion (US) will not be needed.