Kaydet (Commit) 8c414b6f authored tarafından Eike Rathke's avatar Eike Rathke

dr78: #i91870# PMT accuracy; patch from <regina>

# HG changeset patch
# User Eike Rathke [er] <eike.rathke@oracle.com>
# Date 1291388863 -3600
# Node ID 4ca136c3f3c8eb330664884c2ff79e2027d8e4eb
# Parent  c2bc2890eae42a85c3f16085f9d7867799554839
üst cdbcb1a0
...@@ -1120,24 +1120,23 @@ void ScInterpreter::ScLIA() ...@@ -1120,24 +1120,23 @@ void ScInterpreter::ScLIA()
} }
} }
double ScInterpreter::ScGetRmz(double fZins, double fZzr, double fBw, double ScInterpreter::ScGetRmz(double fRate, double fNper, double fPv,
double fZw, double fF) double fFv, double fPaytype)
{ {
RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScGetRmz" ); RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScGetRmz" );
double fRmz; double fPayment;
if (fZins == 0.0) if (fRate == 0.0)
fRmz = (fBw + fZw) / fZzr; fPayment = (fPv + fFv) / fNper;
else else
{ {
double fTerm = pow(1.0 + fZins, fZzr); if (fPaytype > 0.0) // payment in advance
if (fF > 0.0) fPayment = (fFv + fPv * exp( fNper * ::rtl::math::log1p(fRate) ) ) * fRate /
fRmz = (fZw * fZins / (fTerm - 1.0) (::rtl::math::expm1( (fNper + 1) * ::rtl::math::log1p(fRate) ) - fRate);
+ fBw * fZins / (1.0 - 1.0 / fTerm)) / (1.0+fZins); else // payment in arrear
else fPayment = (fFv + fPv * exp(fNper * ::rtl::math::log1p(fRate) ) ) * fRate /
fRmz = fZw * fZins / (fTerm - 1.0) ::rtl::math::expm1( fNper * ::rtl::math::log1p(fRate) );
+ fBw * fZins / (1.0 - 1.0 / fTerm);
} }
return -fRmz; return -fPayment;
} }
void ScInterpreter::ScRMZ() void ScInterpreter::ScRMZ()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment