diff options
Diffstat (limited to 'scaddins')
-rw-r--r-- | scaddins/source/analysis/analysishelper.cxx | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/scaddins/source/analysis/analysishelper.cxx b/scaddins/source/analysis/analysishelper.cxx index d3c83ee46854..ec91d46bbe0e 100644 --- a/scaddins/source/analysis/analysishelper.cxx +++ b/scaddins/source/analysis/analysishelper.cxx @@ -2,9 +2,9 @@ * * $RCSfile: analysishelper.cxx,v $ * - * $Revision: 1.41 $ + * $Revision: 1.42 $ * - * last change: $Author: hr $ $Date: 2004-02-04 14:11:40 $ + * last change: $Author: rt $ $Date: 2004-03-02 09:29:14 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -824,28 +824,34 @@ static inline sal_Char GetMaxChar( sal_uInt16 nBase ) } -STRING ConvertFromDec( sal_Int64 nNum, sal_Int64 nMin, sal_Int64 nMax, sal_uInt16 nBase, - sal_Int32 nPlaces, sal_Int32 nMaxPlaces ) THROWDEF_RTE_IAE +STRING ConvertFromDec( double fNum, double fMin, double fMax, sal_uInt16 nBase, + sal_Int32 nPlaces, sal_Int32 nMaxPlaces, sal_Bool bUsePlaces ) THROWDEF_RTE_IAE { - sal_Bool bUsePlaces = nPlaces != 0x80000000; - if( nNum < nMin || nNum > nMax || ( bUsePlaces && ( nPlaces <= 0 || nPlaces > nMaxPlaces ) ) ) + fNum = ::rtl::math::approxFloor( fNum ); + fMin = ::rtl::math::approxFloor( fMin ); + fMax = ::rtl::math::approxFloor( fMax ); + + if( fNum < fMin || fNum > fMax || ( bUsePlaces && ( nPlaces <= 0 || nPlaces > nMaxPlaces ) ) ) THROW_IAE; + sal_Int64 nNum = static_cast< sal_Int64 >( fNum ); sal_Bool bNeg = nNum < 0; if( bNeg ) nNum = sal_Int64( pow( double( nBase ), double( nMaxPlaces ) ) ) + nNum; STRING aRet( STRING::valueOf( nNum, nBase ).toAsciiUpperCase() ); - sal_Int32 nLen = aRet.getLength(); if( bUsePlaces ) { + sal_Int32 nLen = aRet.getLength(); if( !bNeg && nLen > nPlaces ) + { THROW_IAE; + } else if( ( bNeg && nLen < nMaxPlaces ) || ( !bNeg && nLen < nPlaces ) ) { - sal_uInt32 nLeft = nPlaces - nLen; + sal_Int32 nLeft = nPlaces - nLen; sal_Char* p = new sal_Char[ nLeft + 1 ]; memset( p, bNeg? GetMaxChar( nBase ) : '0', nLeft ); p[ nLeft ] = 0x00; |