[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [5007] Refactor
From: |
Greg Chicares |
Subject: |
[lmi-commits] [5007] Refactor |
Date: |
Tue, 22 Jun 2010 14:12:35 +0000 |
Revision: 5007
http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=5007
Author: chicares
Date: 2010-06-22 14:12:34 +0000 (Tue, 22 Jun 2010)
Log Message:
-----------
Refactor
Modified Paths:
--------------
lmi/trunk/ChangeLog
lmi/trunk/ieee754.hpp
lmi/trunk/ihs_basicval.cpp
Modified: lmi/trunk/ChangeLog
===================================================================
--- lmi/trunk/ChangeLog 2010-06-22 13:42:42 UTC (rev 5006)
+++ lmi/trunk/ChangeLog 2010-06-22 14:12:34 UTC (rev 5007)
@@ -26150,3 +26150,15 @@
ncnnnpnn_test.cpp
Improve documentation.
+20100622T1342Z <address@hidden> [700]
+
+ ieee754.hpp
+ ieee754_test.cpp
+Support infinities.
+
+20100622T1412Z <address@hidden> [699]
+
+ ieee754.hpp
+ ihs_basicval.cpp
+Refactor.
+
Modified: lmi/trunk/ieee754.hpp
===================================================================
--- lmi/trunk/ieee754.hpp 2010-06-22 13:42:42 UTC (rev 5006)
+++ lmi/trunk/ieee754.hpp 2010-06-22 14:12:34 UTC (rev 5007)
@@ -128,5 +128,23 @@
return has_inf && (pos_inf == t || neg_inf == t);
}
+/// Floating-point numbers that represent integers scaled by negative
+/// powers of ten are inexact. For example, a premium rate of $2.40
+/// per $1000 is notionally 0.0024, but to the hardware may look like:
+/// 0.0023999999999999998 [0x3ff69d495182a9930800]
+/// Multiplying that number by a million dollars and rounding down to
+/// cents yields 2399.99, where 2400.00 is wanted.
+///
+/// SOMEDAY !! The best way to handle this is to store integers. For
+/// the time being, multiplying by 1 + LDBL_EPSILON in problematic
+/// circumstances avoids this embarrassment while introducing an error
+/// that shouldn't matter.
+
+inline long double ldbl_eps_plus_one()
+{
+ static long double const z = 1.0L + std::numeric_limits<long
double>::epsilon();
+ return z;
+}
+
#endif // ieee754_hpp
Modified: lmi/trunk/ihs_basicval.cpp
===================================================================
--- lmi/trunk/ihs_basicval.cpp 2010-06-22 13:42:42 UTC (rev 5006)
+++ lmi/trunk/ihs_basicval.cpp 2010-06-22 14:12:34 UTC (rev 5007)
@@ -40,6 +40,7 @@
#include "et_vector.hpp"
#include "fund_data.hpp"
#include "global_settings.hpp"
+#include "ieee754.hpp" // ldbl_eps_plus_one()
#include "ihs_irc7702.hpp"
#include "ihs_irc7702a.hpp"
#include "ihs_x_type.hpp"
@@ -66,27 +67,6 @@
#include <sstream>
#include <stdexcept>
-namespace
-{
- // TODO ?? This is a kludge.
- //
- // Floating-point numbers that represent integers scaled by
- // negative powers of ten are inexact. For example, a premium
- // rate of $2.40 per $1000 is notionally 0.0024, but to the
- // hardware it may look like
- // 0.0023999999999999998 [0x3ff69d495182a9930800]
- // Multiplying that number by a million dollars and rounding
- // down to cents yields 2399.99, where 2400.00 is wanted.
- //
- // The best way to handle this is to store integers. Until we
- // have time to consider that, multiplying by 1 + LDBL_EPSILON
- // avoids this embarrassment while introducing an error that
- // shouldn't matter.
- long double const epsilon_plus_one =
- 1.0L + std::numeric_limits<long double>::epsilon()
- ;
-} // Unnamed namespace.
-
//============================================================================
BasicValues::BasicValues(Input const& input)
:Input_ (new Input(input))
@@ -1142,7 +1122,7 @@
) const
{
double temp = MortalityRates_->SevenPayRates()[0];
- return round_max_premium()(temp * epsilon_plus_one * a_specamt / a_mode);
+ return round_max_premium()(temp * ldbl_eps_plus_one() * a_specamt /
a_mode);
}
/// Calculate premium using a target-premium ratio.
@@ -1161,7 +1141,7 @@
(
( Database_->Query(DB_TgtPremMonthlyPolFee)
+ a_specamt
- * epsilon_plus_one
+ * ldbl_eps_plus_one()
* MortalityRates_->TargetPremiumRates()[0]
)
/ a_mode
@@ -1181,7 +1161,7 @@
) const
{
double temp = GetCorridorFactor()[0];
- return round_max_premium()((epsilon_plus_one * a_specamt / temp) / a_mode);
+ return round_max_premium()((ldbl_eps_plus_one() * a_specamt / temp) /
a_mode);
}
//============================================================================
@@ -1205,7 +1185,7 @@
// term rider, dumpin
z /= a_mode;
- return round_max_premium()(epsilon_plus_one * z);
+ return round_max_premium()(ldbl_eps_plus_one() * z);
}
//============================================================================
@@ -1228,7 +1208,7 @@
// term rider, dumpin
z /= a_mode;
- return round_max_premium()(epsilon_plus_one * z);
+ return round_max_premium()(ldbl_eps_plus_one() * z);
}
/// Determine an approximate "pay as you go" modal premium.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [lmi-commits] [5007] Refactor,
Greg Chicares <=