lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master ac8dde2 2/4: Keep integers integral


From: Greg Chicares
Subject: [lmi-commits] [lmi] master ac8dde2 2/4: Keep integers integral
Date: Sun, 18 Mar 2018 20:02:19 -0400 (EDT)

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

    Keep integers integral
    
    As suggested in the last commit message, rewrote a few lines so that a
    double, once converted to int, is stored as such, and no unnecessary
    mixed-mode arithmetic is subsequently performed upon it.
---
 miscellany.cpp | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/miscellany.cpp b/miscellany.cpp
index 7cd0fff..a15f960 100644
--- a/miscellany.cpp
+++ b/miscellany.cpp
@@ -135,10 +135,8 @@ int scale_power(int max_power, double min_value, double 
max_value)
         return 0;
         }
 
-    double d = static_cast<int>(std::log10(widest));
-    d = std::floor(d / 3.0);
-    int k = 3 * static_cast<int>(d);
-    k = k - 6;
+    int k = static_cast<int>(std::log10(widest));
+    k = 3 * (k / 3) - 6;
 
     LMI_ASSERT(0 <= k);
     LMI_ASSERT(k <= 18);



reply via email to

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