lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master 1c1bafa 2/3: Further document a MinGW-w64 gcc


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 1c1bafa 2/3: Further document a MinGW-w64 gcc-7.2.0 anomaly
Date: Thu, 15 Mar 2018 11:24:31 -0400 (EDT)

branch: master
commit 1c1bafa402cb625a465ce6d87ab72185bcf5eca1
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Further document a MinGW-w64 gcc-7.2.0 anomaly
    
    floor() and trunc() yield different results for a particular floating-
    point argument slightly different from positive three. To reproduce:
      File | New | Illustration
      "Face" tab: append "000" to "Specified amount"
      "Payments" tab: append "000" to "Individual payment"
      OK
      File | Print to PDF
    Values are scaled by 10^3N when they would be too enormous to fit in
    a column with print mask "999,999,999"; in this case, 3N is about 3.
    (It's calculated as -log10(0.001), which isn't exactly int(3).)
    
    Observed output produced by this stream insertion:
        << "\n  " << (power)             << " logarithm"
        << "\n  " << (std::floor(power)) << " floor()"
        << "\n  " << (std::trunc(power)) << " trunc()"
    is
      3 logarithm
      2 floor()
      3 trunc()
    but floor() and trunc() should give the same result.
---
 ledger_base.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/ledger_base.cpp b/ledger_base.cpp
index 3a1842d..2553a60 100644
--- a/ledger_base.cpp
+++ b/ledger_base.cpp
@@ -362,8 +362,12 @@ namespace
             long double discrepancy1 = power - std::ceil (power);
             warning()
                 << "Scaling factor is not an integral power of ten."
+                << "\n  " <<                        (power)             << " 
logarithm"
+                << "\n  " <<                        (std::floor(power)) << " 
floor()"
+                << "\n  " <<                        (std::trunc(power)) << " 
trunc()"
                 << "\n  " << value_cast<std::string>(power)             << " 
logarithm"
-                << "\n  " << value_cast<std::string>(std::floor(power)) << " 
integer"
+                << "\n  " << value_cast<std::string>(std::floor(power)) << " 
floor()"
+                << "\n  " << value_cast<std::string>(std::trunc(power)) << " 
trunc()"
                 << "\n  " << value_cast<std::string>(discrepancy0) << " lower 
difference"
                 << "\n  " << value_cast<std::string>(discrepancy1) << " upper 
difference"
                 << LMI_FLUSH



reply via email to

[Prev in Thread] Current Thread [Next in Thread]