summaryrefslogtreecommitdiff
path: root/scaddins/source
diff options
context:
space:
mode:
authorDaniel Rentz <dr@openoffice.org>2001-09-26 08:51:58 +0000
committerDaniel Rentz <dr@openoffice.org>2001-09-26 08:51:58 +0000
commitf5b732c43a9ed9ace11412d85dacd96d849fcde1 (patch)
tree1dcf7e58e67c7ea1fb55b4fc9072a51aae3817e1 /scaddins/source
parentb4a5f75e3fbdd9495024334c5000b6ffdaa4ea9f (diff)
#89901# check all double results on overrun
Diffstat (limited to 'scaddins/source')
-rw-r--r--scaddins/source/analysis/analysis.cxx87
-rw-r--r--scaddins/source/analysis/analysisdefs.hxx8
-rw-r--r--scaddins/source/analysis/analysishelper.cxx9
-rw-r--r--scaddins/source/analysis/analysishelper.hxx6
-rw-r--r--scaddins/source/analysis/financial.cxx128
5 files changed, 146 insertions, 92 deletions
diff --git a/scaddins/source/analysis/analysis.cxx b/scaddins/source/analysis/analysis.cxx
index ab87492be1f2..13e68dbf5008 100644
--- a/scaddins/source/analysis/analysis.cxx
+++ b/scaddins/source/analysis/analysis.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: analysis.cxx,v $
*
- * $Revision: 1.26 $
+ * $Revision: 1.27 $
*
- * last change: $Author: gt $ $Date: 2001-08-09 14:22:48 $
+ * last change: $Author: dr $ $Date: 2001-09-26 09:51:58 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -667,7 +667,8 @@ sal_Int32 SAL_CALL AnalysisAddIn::getWorkday( constREFXPS& xOptions,
double SAL_CALL AnalysisAddIn::getYearfrac( constREFXPS& xOpt,
sal_Int32 nStartDate, sal_Int32 nEndDate, const ANY& rMode ) THROWDEF_RTE_IAE
{
- return GetYearFrac( xOpt, nStartDate, nEndDate, GetOptBase( rMode ) );
+ double fRet = GetYearFrac( xOpt, nStartDate, nEndDate, GetOptBase( rMode ) );
+ RETURN_FINITE( fRet );
}
@@ -808,10 +809,11 @@ double SAL_CALL AnalysisAddIn::getMultinomial( const SEQSEQ( sal_Int32 )& aV ) T
}
}
- if( nZ <= 170 )
- return Fak( nZ ) / fN;
- else
+ if( nZ > 170 )
THROW_IAE;
+
+ double fRet = Fak( nZ ) / fN;
+ RETURN_FINITE( fRet );
}
@@ -841,13 +843,14 @@ double SAL_CALL AnalysisAddIn::getSeriessum( double fX, double fN, double fM, co
}
}
- return fRet;
+ RETURN_FINITE( fRet );
}
double SAL_CALL AnalysisAddIn::getQuotient( double fNum, double fDenum ) THROWDEF_RTE_IAE
{
- return SolarMath::ApproxFloor( fNum / fDenum );
+ double fRet = SolarMath::ApproxFloor( fNum / fDenum );
+ RETURN_FINITE( fRet );
}
@@ -856,13 +859,15 @@ double SAL_CALL AnalysisAddIn::getMround( double fNum, double fMult ) THROWDEF_R
if( fMult == 0.0 )
return fMult;
- return fMult * SolarMath::Round( fNum / fMult );
+ double fRet = fMult * SolarMath::Round( fNum / fMult );
+ RETURN_FINITE( fRet );
}
double SAL_CALL AnalysisAddIn::getSqrtpi( double fNum ) THROWDEF_RTE_IAE
{
- return sqrt( fNum * PI );
+ double fRet = sqrt( fNum * PI );
+ RETURN_FINITE( fRet );
}
@@ -879,7 +884,8 @@ double SAL_CALL AnalysisAddIn::getRandbetween( double fMin, double fMax ) THROWD
fMax -= fMin;
fMax /= double( RAND_MAX );
- return SolarMath::Round( fMin + fMax * double( rand() ) );
+ double fRet = SolarMath::Round( fMin + fMax * double( rand() ) );
+ RETURN_FINITE( fRet );
}
@@ -904,7 +910,7 @@ double SAL_CALL AnalysisAddIn::getGcd( const SEQSEQ( double )& aVLst, const SEQ(
p = aValList.Next();
}
- return f;
+ RETURN_FINITE( f );
}
@@ -936,19 +942,21 @@ double SAL_CALL AnalysisAddIn::getLcm( const SEQSEQ( ANY )& aVLst, const SEQ( un
p = aValList.Next();
}
- return f;
+ RETURN_FINITE( f );
}
double SAL_CALL AnalysisAddIn::getBesseli( double fNum, sal_Int32 nOrder ) THROWDEF_RTE_IAE
{
- return Bessel( fNum, nOrder, sal_True );
+ double fRet = Bessel( fNum, nOrder, sal_True );
+ RETURN_FINITE( fRet );
}
double SAL_CALL AnalysisAddIn::getBesselj( double fNum, sal_Int32 nOrder ) THROWDEF_RTE_IAE
{
- return Bessel( fNum, nOrder, sal_False );
+ double fRet = Bessel( fNum, nOrder, sal_False );
+ RETURN_FINITE( fRet );
}
@@ -957,7 +965,8 @@ double SAL_CALL AnalysisAddIn::getBesselk( double fNum, sal_Int32 nOrder ) THROW
if( nOrder < 0 || fNum <= 0.0 )
THROW_IAE;
- return Besselk( fNum, nOrder );
+ double fRet = Besselk( fNum, nOrder );
+ RETURN_FINITE( fRet );
}
@@ -967,7 +976,8 @@ double SAL_CALL AnalysisAddIn::getBessely( double fNum, sal_Int32 nOrder ) THROW
THROW_IAE;
// return yn( nOrder, fNum );
- return Bessely( fNum, nOrder );
+ double fRet = Bessely( fNum, nOrder );
+ RETURN_FINITE( fRet );
}
@@ -990,7 +1000,8 @@ STRING SAL_CALL AnalysisAddIn::getBin2Oct( const STRING& aNum, const ANY& rPlace
double SAL_CALL AnalysisAddIn::getBin2Dec( const STRING& aNum ) THROWDEF_RTE_IAE
{
- return ConvertToDec( aNum, 2, _P );
+ double fRet = ConvertToDec( aNum, 2, _P );
+ RETURN_FINITE( fRet );
}
@@ -1008,7 +1019,8 @@ STRING SAL_CALL AnalysisAddIn::getOct2Bin( const STRING& aNum, const ANY& rPlace
double SAL_CALL AnalysisAddIn::getOct2Dec( const STRING& aNum ) THROWDEF_RTE_IAE
{
- return ConvertToDec( aNum, 8, _P );
+ double fRet = ConvertToDec( aNum, 8, _P );
+ RETURN_FINITE( fRet );
}
@@ -1044,7 +1056,8 @@ STRING SAL_CALL AnalysisAddIn::getHex2Bin( const STRING& aNum, const ANY& rPlace
double SAL_CALL AnalysisAddIn::getHex2Dec( const STRING& aNum ) THROWDEF_RTE_IAE
{
- return ConvertToDec( aNum, 16, _P );
+ double fRet = ConvertToDec( aNum, 16, _P );
+ RETURN_FINITE( fRet );
}
@@ -1066,26 +1079,30 @@ sal_Int32 SAL_CALL AnalysisAddIn::getDelta( double fNum1, const ANY& rNum2 ) THR
double SAL_CALL AnalysisAddIn::getErf( double fLL, const ANY& rUL ) THROWDEF_RTE_IAE
{
+ double fRet;
switch( rUL.getValueTypeClass() )
{
case uno::TypeClass_VOID:
- return Erf( fLL );
+ fRet = Erf( fLL );
break;
case uno::TypeClass_DOUBLE:
+ {
double fUL = *( double* ) rUL.getValue();
- return Erf( fUL ) - Erf( fLL );
+ fRet = Erf( fUL ) - Erf( fLL );
+ }
break;
+ default:
+ THROW_IAE;
}
- THROW_IAE;
-
- return 0.0;
+ RETURN_FINITE( fRet );
}
double SAL_CALL AnalysisAddIn::getErfc( double f ) THROWDEF_RTE_IAE
{
- return 1.0 - Erf( f );
+ double fRet = 1.0 - Erf( f );
+ RETURN_FINITE( fRet );
}
@@ -1101,19 +1118,22 @@ sal_Int32 SAL_CALL AnalysisAddIn::getGestep( double fNum, const ANY& rStep ) THR
double SAL_CALL AnalysisAddIn::getFactdouble( sal_Int32 nNum ) THROWDEF_RTE_IAE
{
- return FactDouble( nNum );
+ double fRet = FactDouble( nNum );
+ RETURN_FINITE( fRet );
}
double SAL_CALL AnalysisAddIn::getImabs( const STRING& aNum ) THROWDEF_RTE_IAE
{
- return Complex( aNum ).Abs();
+ double fRet = Complex( aNum ).Abs();
+ RETURN_FINITE( fRet );
}
double SAL_CALL AnalysisAddIn::getImaginary( const STRING& aNum ) THROWDEF_RTE_IAE
{
- return Complex( aNum ).Imag();
+ double fRet = Complex( aNum ).Imag();
+ RETURN_FINITE( fRet );
}
@@ -1129,7 +1149,8 @@ STRING SAL_CALL AnalysisAddIn::getImpower( const STRING& aNum, double f ) THROWD
double SAL_CALL AnalysisAddIn::getImargument( const STRING& aNum ) THROWDEF_RTE_IAE
{
- return Complex( aNum ).Arg();
+ double fRet = Complex( aNum ).Arg();
+ RETURN_FINITE( fRet );
}
@@ -1226,7 +1247,8 @@ STRING SAL_CALL AnalysisAddIn::getImproduct( const SEQSEQ( STRING )& aNum1, cons
double SAL_CALL AnalysisAddIn::getImreal( const STRING& aNum ) THROWDEF_RTE_IAE
{
- return Complex( aNum ).Real();
+ double fRet = Complex( aNum ).Real();
+ RETURN_FINITE( fRet );
}
@@ -1312,7 +1334,8 @@ double SAL_CALL AnalysisAddIn::getConvert( double f, const STRING& aFU, const ST
if( !pCDL )
pCDL = new ConvertDataList();
- return pCDL->Convert( f, aFU, aTU );
+ double fRet = pCDL->Convert( f, aFU, aTU );
+ RETURN_FINITE( fRet );
}
diff --git a/scaddins/source/analysis/analysisdefs.hxx b/scaddins/source/analysis/analysisdefs.hxx
index 0ae62574d572..2fb729cb11e2 100644
--- a/scaddins/source/analysis/analysisdefs.hxx
+++ b/scaddins/source/analysis/analysisdefs.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: analysisdefs.hxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: gt $ $Date: 2001-06-18 13:00:32 $
+ * last change: $Author: dr $ $Date: 2001-09-26 09:51:58 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -79,7 +79,9 @@
#define THROWDEF_RTE_IAE throw(CSS::uno::RuntimeException,CSS::lang::IllegalArgumentException)
#define THROW_IAE throw CSS::lang::IllegalArgumentException()
-#define CHK_Freq ( nFreq != 1 && nFreq != 2 && nFreq != 4 )
+#define CHK_Freq ( nFreq != 1 && nFreq != 2 && nFreq != 4 )
+#define CHK_FINITE(d) if( !SOMA_FINITE( d ) ) THROW_IAE
+#define RETURN_FINITE(d) if( SOMA_FINITE( d ) ) return d; else THROW_IAE
#endif
diff --git a/scaddins/source/analysis/analysishelper.cxx b/scaddins/source/analysis/analysishelper.cxx
index 56ed7d4975bf..3cbb3c533f37 100644
--- a/scaddins/source/analysis/analysishelper.cxx
+++ b/scaddins/source/analysis/analysishelper.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: analysishelper.cxx,v $
*
- * $Revision: 1.29 $
+ * $Revision: 1.30 $
*
- * last change: $Author: gt $ $Date: 2001-08-31 08:23:29 $
+ * last change: $Author: dr $ $Date: 2001-09-26 09:51:58 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -63,6 +63,7 @@
#include <string.h>
#include <stdio.h>
#include <vcl/resary.hxx>
+#include <tools/solmath.hxx>
#include "analysishelper.hxx"
#include "analysis.hrc"
@@ -2774,13 +2775,15 @@ sal_Bool Complex::ParseString( const STRING& rStr, Complex& rCompl )
}
-STRING Complex::GetString( sal_Bool bi ) const
+STRING Complex::GetString( sal_Bool bi ) const THROWDEF_RTE_IAE
{
static const STRING aI( "i", 1, RTL_TEXTENCODING_MS_1252 );
static const STRING aJ( "j", 1, RTL_TEXTENCODING_MS_1252 );
static const STRING aPlus( "+", 1, RTL_TEXTENCODING_MS_1252 );
static const STRING aMinus( "-", 1, RTL_TEXTENCODING_MS_1252 );
+ CHK_FINITE(r);
+ CHK_FINITE(i);
STRING aRet( ::GetString( r ) );
if( i == 1.0 )
diff --git a/scaddins/source/analysis/analysishelper.hxx b/scaddins/source/analysis/analysishelper.hxx
index bb8c234ef1d5..e7403755e8d1 100644
--- a/scaddins/source/analysis/analysishelper.hxx
+++ b/scaddins/source/analysis/analysishelper.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: analysishelper.hxx,v $
*
- * $Revision: 1.16 $
+ * $Revision: 1.17 $
*
- * last change: $Author: gt $ $Date: 2001-08-23 16:13:18 $
+ * last change: $Author: dr $ $Date: 2001-09-26 09:51:58 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -547,7 +547,7 @@ public:
inline static sal_Bool IsImagUnit( sal_Unicode c );
static sal_Bool ParseString( const STRING& rComplexAsString, Complex& rReturn );
- STRING GetString( sal_Bool bUse_i = sal_True ) const;
+ STRING GetString( sal_Bool bUse_i = sal_True ) const THROWDEF_RTE_IAE;
inline double Real( void ) const;
inline double Imag( void ) const;
diff --git a/scaddins/source/analysis/financial.cxx b/scaddins/source/analysis/financial.cxx
index 298c64f93538..5162be452efd 100644
--- a/scaddins/source/analysis/financial.cxx
+++ b/scaddins/source/analysis/financial.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: financial.cxx,v $
*
- * $Revision: 1.11 $
+ * $Revision: 1.12 $
*
- * last change: $Author: gt $ $Date: 2001-08-23 16:13:18 $
+ * last change: $Author: dr $ $Date: 2001-09-26 09:51:58 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -61,6 +61,7 @@
#include "analysis.hxx"
#include "analysishelper.hxx"
+#include <tools/solmath.hxx>
@@ -72,7 +73,8 @@ double SAL_CALL AnalysisAddIn::getAmordegrc( constREFXPS& xOpt,
if( nDate > nFirstPer || fRate <= 0.0 || fRestVal > fCost )
THROW_IAE;
- return GetAmordegrc( GetNullDate( xOpt ), fCost, nDate, nFirstPer, fRestVal, fPer, fRate, GetOptBase( rOB ) );
+ double fRet = GetAmordegrc( GetNullDate( xOpt ), fCost, nDate, nFirstPer, fRestVal, fPer, fRate, GetOptBase( rOB ) );
+ RETURN_FINITE( fRet );
}
@@ -83,7 +85,8 @@ double SAL_CALL AnalysisAddIn::getAmorlinc( constREFXPS& xOpt,
if( nDate > nFirstPer || fRate <= 0.0 || fRestVal > fCost )
THROW_IAE;
- return GetAmorlinc( GetNullDate( xOpt ), fCost, nDate, nFirstPer, fRestVal, fPer, fRate, GetOptBase( rOB ) );
+ double fRet = GetAmorlinc( GetNullDate( xOpt ), fCost, nDate, nFirstPer, fRestVal, fPer, fRate, GetOptBase( rOB ) );
+ RETURN_FINITE( fRet );
}
@@ -94,7 +97,8 @@ double SAL_CALL AnalysisAddIn::getAccrint( constREFXPS& xOpt,
if( fRate <= 0.0 || fVal <= 0.0 || CHK_Freq || nIssue >= nSettle )
THROW_IAE;
- return fVal * fRate * GetYearDiff( GetNullDate( xOpt ), nIssue, nSettle, GetOptBase( rOB ) );
+ double fRet = fVal * fRate * GetYearDiff( GetNullDate( xOpt ), nIssue, nSettle, GetOptBase( rOB ) );
+ RETURN_FINITE( fRet );
}
@@ -106,7 +110,8 @@ double SAL_CALL AnalysisAddIn::getAccrintm( constREFXPS& xOpt,
if( fRate <= 0.0 || fVal <= 0.0 || nIssue >= nSettle )
THROW_IAE;
- return fVal * fRate * GetYearDiff( GetNullDate( xOpt ), nIssue, nSettle, GetOptBase( rOB ) );
+ double fRet = fVal * fRate * GetYearDiff( GetNullDate( xOpt ), nIssue, nSettle, GetOptBase( rOB ) );
+ RETURN_FINITE( fRet );
}
@@ -116,7 +121,8 @@ double SAL_CALL AnalysisAddIn::getReceived( constREFXPS& xOpt,
if( fInvest <= 0.0 || fDisc <= 0.0 )
THROW_IAE;
- return fInvest / ( 1.0 - ( fDisc * GetYearDiff( GetNullDate( xOpt ), nSettle, nMat, GetOptBase( rOB ) ) ) );
+ double fRet = fInvest / ( 1.0 - ( fDisc * GetYearDiff( GetNullDate( xOpt ), nSettle, nMat, GetOptBase( rOB ) ) ) );
+ RETURN_FINITE( fRet );
}
@@ -125,7 +131,8 @@ double SAL_CALL AnalysisAddIn::getDisc( constREFXPS& xOpt,
{
if( fPrice <= 0.0 || fRedemp <= 0.0 || nSettle >= nMat )
THROW_IAE;
- return ( 1.0 - fPrice / fRedemp ) / GetYearFrac( xOpt, nSettle, nMat, GetOptBase( rOB ) );
+ double fRet = ( 1.0 - fPrice / fRedemp ) / GetYearFrac( xOpt, nSettle, nMat, GetOptBase( rOB ) );
+ RETURN_FINITE( fRet );
}
@@ -136,7 +143,8 @@ double SAL_CALL AnalysisAddIn::getDuration( constREFXPS& xOpt,
if( fCoup < 0.0 || fYield < 0.0 || CHK_Freq || nSettle >= nMat )
THROW_IAE;
- return GetDuration( GetNullDate( xOpt ), nSettle, nMat, fCoup, fYield, nFreq, GetOptBase( rOB ) );
+ double fRet = GetDuration( GetNullDate( xOpt ), nSettle, nMat, fCoup, fYield, nFreq, GetOptBase( rOB ) );
+ RETURN_FINITE( fRet );
}
@@ -147,7 +155,8 @@ double SAL_CALL AnalysisAddIn::getEffect( double fNominal, sal_Int32 nPeriods )
double fPeriods = nPeriods;
- return pow( 1.0 + fNominal / fPeriods, fPeriods ) - 1.0;
+ double fRet = pow( 1.0 + fNominal / fPeriods, fPeriods ) - 1.0;
+ RETURN_FINITE( fRet );
}
@@ -164,20 +173,20 @@ double SAL_CALL AnalysisAddIn::getCumprinc( double fRate, sal_Int32 nNumPeriods,
fKapZ = 0.0;
- sal_uInt32 nAnfang = sal_uInt32( nStartPer );
- sal_uInt32 nEnde = sal_uInt32( nEndPer );
+ sal_uInt32 nStart = sal_uInt32( nStartPer );
+ sal_uInt32 nEnd = sal_uInt32( nEndPer );
- if( nAnfang == 1 )
+ if( nStart == 1 )
{
if( nPayType <= 0 )
fKapZ = fRmz + fVal * fRate;
else
fKapZ = fRmz;
- nAnfang++;
+ nStart++;
}
- for( sal_uInt32 i = nAnfang ; i <= nEnde ; i++ )
+ for( sal_uInt32 i = nStart ; i <= nEnd ; i++ )
{
if( nPayType > 0 )
fKapZ += fRmz - ( GetZw( fRate, double( i - 2 ), fRmz, fVal, 1 ) - fRmz ) * fRate;
@@ -185,7 +194,7 @@ double SAL_CALL AnalysisAddIn::getCumprinc( double fRate, sal_Int32 nNumPeriods,
fKapZ += fRmz - GetZw( fRate, double( i - 1 ), fRmz, fVal, 0 ) * fRate;
}
- return fKapZ;
+ RETURN_FINITE( fKapZ );
}
@@ -202,18 +211,18 @@ double SAL_CALL AnalysisAddIn::getCumipmt( double fRate, sal_Int32 nNumPeriods,
fZinsZ = 0.0;
- sal_uInt32 nAnfang = sal_uInt32( nStartPer );
- sal_uInt32 nEnde = sal_uInt32( nEndPer );
+ sal_uInt32 nStart = sal_uInt32( nStartPer );
+ sal_uInt32 nEnd = sal_uInt32( nEndPer );
- if( nAnfang == 1 )
+ if( nStart == 1 )
{
if( nPayType <= 0 )
fZinsZ = -fVal;
- nAnfang++;
+ nStart++;
}
- for( sal_uInt32 i = nAnfang ; i <= nEnde ; i++ )
+ for( sal_uInt32 i = nStart ; i <= nEnd ; i++ )
{
if( nPayType > 0 )
fZinsZ += GetZw( fRate, double( i - 2 ), fRmz, fVal, 1 ) - fRmz;
@@ -223,7 +232,7 @@ double SAL_CALL AnalysisAddIn::getCumipmt( double fRate, sal_Int32 nNumPeriods,
fZinsZ *= fRate;
- return fZinsZ;
+ RETURN_FINITE( fZinsZ );
}
@@ -234,7 +243,8 @@ double SAL_CALL AnalysisAddIn::getPrice( constREFXPS& xOpt,
if( fYield < 0.0 || fRate < 0.0 || fRedemp <= 0 || CHK_Freq || nSettle >= nMat )
THROW_IAE;
- return getPrice_( GetNullDate( xOpt ), nSettle, nMat, fRate, fYield, fRedemp, nFreq, GetOptBase( rOB ) );
+ double fRet = getPrice_( GetNullDate( xOpt ), nSettle, nMat, fRate, fYield, fRedemp, nFreq, GetOptBase( rOB ) );
+ RETURN_FINITE( fRet );
}
@@ -244,7 +254,8 @@ double SAL_CALL AnalysisAddIn::getPricedisc( constREFXPS& xOpt,
if( fDisc <= 0.0 || fRedemp <= 0 || nSettle >= nMat )
THROW_IAE;
- return fRedemp * ( 1.0 - fDisc * GetYearDiff( GetNullDate( xOpt ), nSettle, nMat, GetOptBase( rOB ) ) );
+ double fRet = fRedemp * ( 1.0 - fDisc * GetYearDiff( GetNullDate( xOpt ), nSettle, nMat, GetOptBase( rOB ) ) );
+ RETURN_FINITE( fRet );
}
@@ -267,7 +278,7 @@ double SAL_CALL AnalysisAddIn::getPricemat( constREFXPS& xOpt,
fRet -= fIssSet * fRate;
fRet *= 100.0;
- return fRet;
+ RETURN_FINITE( fRet );
}
@@ -282,7 +293,7 @@ double SAL_CALL AnalysisAddIn::getMduration( constREFXPS& xOpt,
double fRet = GetDuration( GetNullDate( xOpt ), nSettle, nMat, fCoup, fYield, nFreq, GetOptBase( rOB ) );
fRet /= 1.0 + ( fYield / double( nFreq ) );
- return fRet;
+ RETURN_FINITE( fRet );
}
@@ -292,7 +303,8 @@ double SAL_CALL AnalysisAddIn::getNominal( double fRate, sal_Int32 nPeriods ) TH
THROW_IAE;
double fPeriods = nPeriods;
- return ( pow( fRate + 1.0, 1.0 / fPeriods ) - 1.0 ) * fPeriods;
+ double fRet = ( pow( fRate + 1.0, 1.0 / fPeriods ) - 1.0 ) * fPeriods;
+ RETURN_FINITE( fRet );
}
@@ -312,7 +324,7 @@ double SAL_CALL AnalysisAddIn::getDollarfr( double fDollarDec, sal_Int32 nFrac )
fRet += fInt;
- return fRet;
+ RETURN_FINITE( fRet );
}
@@ -332,7 +344,7 @@ double SAL_CALL AnalysisAddIn::getDollarde( double fDollarFrac, sal_Int32 nFrac
fRet += fInt;
- return fRet;
+ RETURN_FINITE( fRet );
}
@@ -343,7 +355,8 @@ double SAL_CALL AnalysisAddIn::getYield( constREFXPS& xOpt,
if( fCoup < 0.0 || fPrice <= 0.0 || fRedemp <= 0.0 || CHK_Freq || nSettle >= nMat )
THROW_IAE;
- return getYield_( GetNullDate( xOpt ), nSettle, nMat, fCoup, fPrice, fRedemp, nFreq, GetOptBase( rOB ) );
+ double fRet = getYield_( GetNullDate( xOpt ), nSettle, nMat, fCoup, fPrice, fRedemp, nFreq, GetOptBase( rOB ) );
+ RETURN_FINITE( fRet );
}
@@ -357,10 +370,9 @@ double SAL_CALL AnalysisAddIn::getYielddisc( constREFXPS& xOpt,
sal_Int32 nNullDate = GetNullDate( xOpt );
double fRet = 1.0 - fPrice / fRedemp;
-// fRet /= GetYearDiff( nNullDate, nSettle, nMat, nBase );
fRet /= GetYearFrac( nNullDate, nSettle, nMat, nBase );
-
- return fRet / 0.99795; // don't know what this constant means in original
+ fRet /= 0.99795; // don't know what this constant means in original
+ RETURN_FINITE( fRet );
}
@@ -371,7 +383,8 @@ double SAL_CALL AnalysisAddIn::getYieldmat( constREFXPS& xOpt,
if( fRate < 0.0 || fRate <= 0.0 || nSettle >= nMat )
THROW_IAE;
- return GetYieldmat( GetNullDate( xOpt ), nSettle, nMat, nIssue, fRate, fPrice, GetOptBase( rOB ) );
+ double fRet = GetYieldmat( GetNullDate( xOpt ), nSettle, nMat, nIssue, fRate, fPrice, GetOptBase( rOB ) );
+ RETURN_FINITE( fRet );
}
@@ -385,7 +398,8 @@ double SAL_CALL AnalysisAddIn::getTbilleq( constREFXPS& xOpt,
if( fDisc <= 0.0 || nSettle >= nMat || nDiff > 360 )
THROW_IAE;
- return ( 365 * fDisc ) / ( 360 - ( fDisc * double( nDiff ) ) );
+ double fRet = ( 365 * fDisc ) / ( 360 - ( fDisc * double( nDiff ) ) );
+ RETURN_FINITE( fRet );
}
@@ -403,7 +417,8 @@ double SAL_CALL AnalysisAddIn::getTbillprice( constREFXPS& xOpt,
if( modf( fFraction, &fDummy ) == 0.0 )
THROW_IAE;
- return 100.0 * ( 1.0 - fDisc * fFraction );
+ double fRet = 100.0 * ( 1.0 - fDisc * fFraction );
+ RETURN_FINITE( fRet );
}
@@ -422,7 +437,7 @@ double SAL_CALL AnalysisAddIn::getTbillyield( constREFXPS& xOpt, sal_Int32 nSett
fRet /= double( nDiff );
fRet *= 360.0;
- return fRet;
+ RETURN_FINITE( fRet );
}
@@ -433,7 +448,8 @@ double SAL_CALL AnalysisAddIn::getOddfprice( constREFXPS& xOpt,
if( fRate < 0 || fYield < 0 || CHK_Freq || nMat <= nFirstCoup || nFirstCoup <= nSettle || nSettle <= nIssue )
THROW_IAE;
- return GetOddfprice( GetNullDate( xOpt ), nSettle, nMat, nIssue, nFirstCoup, fRate, fYield, fRedemp, nFreq, GetOptBase( rOB ) );
+ double fRet = GetOddfprice( GetNullDate( xOpt ), nSettle, nMat, nIssue, nFirstCoup, fRate, fYield, fRedemp, nFreq, GetOptBase( rOB ) );
+ RETURN_FINITE( fRet );
}
@@ -444,8 +460,9 @@ double SAL_CALL AnalysisAddIn::getOddfyield( constREFXPS& xOpt,
if( fRate < 0 || fPrice <= 0 || CHK_Freq || nMat <= nFirstCoup || nFirstCoup <= nSettle || nSettle <= nIssue )
THROW_IAE;
- return GetOddfyield( GetNullDate( xOpt ), nSettle, nMat, nIssue, nFirstCoup, fRate, fPrice, fRedemp, nFreq,
+ double fRet = GetOddfyield( GetNullDate( xOpt ), nSettle, nMat, nIssue, nFirstCoup, fRate, fPrice, fRedemp, nFreq,
GetOptBase( rOB ) );
+ RETURN_FINITE( fRet );
}
@@ -456,8 +473,9 @@ double SAL_CALL AnalysisAddIn::getOddlprice( constREFXPS& xOpt,
if( fRate < 0 || fYield < 0 || CHK_Freq || nMat <= nSettle || nSettle <= nLastInterest )
THROW_IAE;
- return GetOddlprice( GetNullDate( xOpt ), nSettle, nMat, nLastInterest, fRate, fYield, fRedemp, nFreq,
+ double fRet = GetOddlprice( GetNullDate( xOpt ), nSettle, nMat, nLastInterest, fRate, fYield, fRedemp, nFreq,
GetOptBase( rOB ) );
+ RETURN_FINITE( fRet );
}
@@ -468,8 +486,9 @@ double SAL_CALL AnalysisAddIn::getOddlyield( constREFXPS& xOpt,
if( fRate < 0 || fPrice <= 0 || CHK_Freq || nMat <= nSettle || nSettle <= nLastInterest )
THROW_IAE;
- return GetOddlyield( GetNullDate( xOpt ), nSettle, nMat, nLastInterest, fRate, fPrice, fRedemp, nFreq,
+ double fRet = GetOddlyield( GetNullDate( xOpt ), nSettle, nMat, nLastInterest, fRate, fPrice, fRedemp, nFreq,
GetOptBase( rOB ) );
+ RETURN_FINITE( fRet );
}
@@ -541,7 +560,7 @@ double SAL_CALL AnalysisAddIn::getXirr(
}
if( floor( f ) == 0.0 || fabs( fDiff ) <= 1e-10 )
- return fYld;
+ RETURN_FINITE( fYld );
else
THROW_IAE;
}
@@ -568,7 +587,7 @@ double SAL_CALL AnalysisAddIn::getXnpv(
for( sal_Int32 i = 0 ; i < nNum ; i++ )
fRet += *aValList.Get( i ) / ( pow( fRate, ( *aDateList.Get( i ) - fNull ) / 365.0 ) );
- return fRet;
+ RETURN_FINITE( fRet );
}
@@ -578,49 +597,56 @@ double SAL_CALL AnalysisAddIn::getIntrate( constREFXPS& xOpt,
if( fInvest <= 0.0 || fRedemp <= 0.0 || nSettle >= nMat )
THROW_IAE;
- return ( ( fRedemp / fInvest ) - 1.0 ) / GetYearDiff( GetNullDate( xOpt ), nSettle, nMat, GetOptBase( rOB ) );
+ double fRet = ( ( fRedemp / fInvest ) - 1.0 ) / GetYearDiff( GetNullDate( xOpt ), nSettle, nMat, GetOptBase( rOB ) );
+ RETURN_FINITE( fRet );
}
double SAL_CALL AnalysisAddIn::getCoupncd( constREFXPS& xOpt,
sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nFreq, const ANY& rOB ) THROWDEF_RTE_IAE
{
- return GetCoupncd( GetNullDate( xOpt ), nSettle, nMat, nFreq, GetOptBase( rOB ) );
+ double fRet = GetCoupncd( GetNullDate( xOpt ), nSettle, nMat, nFreq, GetOptBase( rOB ) );
+ RETURN_FINITE( fRet );
}
double SAL_CALL AnalysisAddIn::getCoupdays( constREFXPS& xOpt,
sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nFreq, const ANY& rOB ) THROWDEF_RTE_IAE
{
- return GetCoupdays( GetNullDate( xOpt ), nSettle, nMat, nFreq, GetOptBase( rOB ) );
+ double fRet = GetCoupdays( GetNullDate( xOpt ), nSettle, nMat, nFreq, GetOptBase( rOB ) );
+ RETURN_FINITE( fRet );
}
double SAL_CALL AnalysisAddIn::getCoupdaysnc( constREFXPS& xOpt,
sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nFreq, const ANY& rOB ) THROWDEF_RTE_IAE
{
- return GetCoupdaysnc( GetNullDate( xOpt ), nSettle, nMat, nFreq, GetOptBase( rOB ) );
+ double fRet = GetCoupdaysnc( GetNullDate( xOpt ), nSettle, nMat, nFreq, GetOptBase( rOB ) );
+ RETURN_FINITE( fRet );
}
double SAL_CALL AnalysisAddIn::getCoupdaybs( constREFXPS& xOpt,
sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nFreq, const ANY& rOB ) THROWDEF_RTE_IAE
{
- return GetCoupdaybs( GetNullDate( xOpt ), nSettle, nMat, nFreq, GetOptBase( rOB ) );
+ double fRet = GetCoupdaybs( GetNullDate( xOpt ), nSettle, nMat, nFreq, GetOptBase( rOB ) );
+ RETURN_FINITE( fRet );
}
double SAL_CALL AnalysisAddIn::getCouppcd( constREFXPS& xOpt,
sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nFreq, const ANY& rOB ) THROWDEF_RTE_IAE
{
- return GetCouppcd( GetNullDate( xOpt ), nSettle, nMat, nFreq, GetOptBase( rOB ) );
+ double fRet = GetCouppcd( GetNullDate( xOpt ), nSettle, nMat, nFreq, GetOptBase( rOB ) );
+ RETURN_FINITE( fRet );
}
double SAL_CALL AnalysisAddIn::getCoupnum( constREFXPS& xOpt,
sal_Int32 nSettle, sal_Int32 nMat, sal_Int32 nFreq, const ANY& rOB ) THROWDEF_RTE_IAE
{
- return GetCoupnum( GetNullDate( xOpt ), nSettle, nMat, nFreq, GetOptBase( rOB ) );
+ double fRet = GetCoupnum( GetNullDate( xOpt ), nSettle, nMat, nFreq, GetOptBase( rOB ) );
+ RETURN_FINITE( fRet );
}
@@ -633,7 +659,7 @@ double SAL_CALL AnalysisAddIn::getFvschedule( double fPrinc, const SEQSEQ( doubl
for( const double* p = aSchedList.First() ; p ; p = aSchedList.Next() )
fPrinc *= 1.0 + *p;
- return fPrinc;
+ RETURN_FINITE( fPrinc );
}