summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorArnaud Versini <arnaud.versini@gmail.com>2016-11-01 13:50:03 +0100
committerJulien Nabet <serval2412@yahoo.fr>2016-11-06 08:08:50 +0000
commit3db1e9ed4d0d11457684dd3d2c8cacf97d7e3333 (patch)
tree201710c5cb3acb7eb04cb10d22a65c7aced6ddbc /basic
parent4bcf1872bbe9db1388769485a7e4c0cbcce3d53c (diff)
BASIC : remove ImpRound and use std::(l)lround instead
Change-Id: I1e8f58890395bc6bc29f56c258836db3dc52384c Reviewed-on: https://gerrit.libreoffice.org/30464 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Diffstat (limited to 'basic')
-rw-r--r--basic/source/sbx/sbxbyte.cxx6
-rw-r--r--basic/source/sbx/sbxchar.cxx8
-rw-r--r--basic/source/sbx/sbxconv.hxx3
-rw-r--r--basic/source/sbx/sbxint.cxx17
-rw-r--r--basic/source/sbx/sbxlng.cxx8
5 files changed, 22 insertions, 20 deletions
diff --git a/basic/source/sbx/sbxbyte.cxx b/basic/source/sbx/sbxbyte.cxx
index 5527a56f0e5b..562979b4c37e 100644
--- a/basic/source/sbx/sbxbyte.cxx
+++ b/basic/source/sbx/sbxbyte.cxx
@@ -21,6 +21,8 @@
#include <basic/sbx.hxx>
#include "sbxconv.hxx"
+#include <cmath>
+
sal_uInt8 ImpGetByte( const SbxValues* p )
{
SbxValues aTmp;
@@ -121,7 +123,7 @@ start:
SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = 0;
}
else
- nRes = (sal_uInt8) ImpRound( p->nSingle );
+ nRes = (sal_uInt8) std::lround( p->nSingle );
break;
case SbxDATE:
case SbxDOUBLE:
@@ -147,7 +149,7 @@ start:
SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = 0;
}
else
- nRes = (sal_uInt8) ImpRound( dVal );
+ nRes = (sal_uInt8) std::lround( dVal );
break;
}
case SbxBYREF | SbxSTRING:
diff --git a/basic/source/sbx/sbxchar.cxx b/basic/source/sbx/sbxchar.cxx
index d03bcb9a9ff8..81d195c188e1 100644
--- a/basic/source/sbx/sbxchar.cxx
+++ b/basic/source/sbx/sbxchar.cxx
@@ -21,6 +21,8 @@
#include <basic/sbx.hxx>
#include "sbxconv.hxx"
+#include <cmath>
+
sal_Unicode ImpGetChar( const SbxValues* p )
{
SbxValues aTmp;
@@ -109,7 +111,7 @@ start:
SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = SbxMINCHAR;
}
else
- nRes = (sal_Unicode) ImpRound( p->nSingle );
+ nRes = (sal_Unicode) std::lround( p->nSingle );
break;
case SbxDATE:
case SbxDOUBLE:
@@ -135,7 +137,7 @@ start:
SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = SbxMINCHAR;
}
else
- nRes = (sal_uInt8) ImpRound( dVal );
+ nRes = (sal_uInt8) std::lround( dVal );
break;
}
case SbxBYREF | SbxSTRING:
@@ -156,7 +158,7 @@ start:
SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = SbxMINCHAR;
}
else
- nRes = (sal_Unicode) ImpRound( d );
+ nRes = (sal_Unicode) std::lround( d );
}
break;
case SbxOBJECT:
diff --git a/basic/source/sbx/sbxconv.hxx b/basic/source/sbx/sbxconv.hxx
index c14a3ac5bc1a..08fa296f2c8f 100644
--- a/basic/source/sbx/sbxconv.hxx
+++ b/basic/source/sbx/sbxconv.hxx
@@ -37,8 +37,7 @@ void ImpGetIntntlSep( sal_Unicode& rcDecimalSep, sal_Unicode& rcThousandSep );
// SBXINT.CXX
-double ImpRound( double );
-sal_Int16 ImpGetInteger( const SbxValues* );
+sal_Int16 ImpGetInteger( const SbxValues* );
void ImpPutInteger( SbxValues*, sal_Int16 );
sal_Int64 ImpGetInt64( const SbxValues* );
diff --git a/basic/source/sbx/sbxint.cxx b/basic/source/sbx/sbxint.cxx
index c2d6fbe3d3eb..b3d4cd30433b 100644
--- a/basic/source/sbx/sbxint.cxx
+++ b/basic/source/sbx/sbxint.cxx
@@ -21,10 +21,7 @@
#include <basic/sbx.hxx>
#include "sbxconv.hxx"
-double ImpRound( double d )
-{
- return d + ( d < 0 ? -0.5 : 0.5 );
-}
+#include <cmath>
sal_Int16 ImpGetInteger( const SbxValues* p )
{
@@ -84,7 +81,7 @@ start:
SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = SbxMININT;
}
else
- nRes = (sal_Int16) ImpRound( p->nSingle );
+ nRes = (sal_Int16) std::lround( p->nSingle );
break;
case SbxCURRENCY:
{
@@ -145,7 +142,7 @@ start:
SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = SbxMININT;
}
else
- nRes = (sal_Int16) ImpRound( dVal );
+ nRes = (sal_Int16) std::lround( dVal );
break;
}
case SbxLPSTR:
@@ -168,7 +165,7 @@ start:
SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = SbxMININT;
}
else
- nRes = (sal_Int16) ImpRound( d );
+ nRes = (sal_Int16) std::lround( d );
}
break;
case SbxOBJECT:
@@ -350,7 +347,7 @@ sal_Int64 ImpDoubleToSalInt64( double d )
SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = SbxMINSALINT64;
}
else
- nRes = (sal_Int64) ImpRound( d );
+ nRes = (sal_Int64) std::llround( d );
return nRes;
}
@@ -366,7 +363,7 @@ sal_uInt64 ImpDoubleToSalUInt64( double d )
SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = 0;
}
else
- nRes = (sal_uInt64) ImpRound( d );
+ nRes = (sal_uInt64) std::llround( d );
return nRes;
}
@@ -716,7 +713,7 @@ start:
SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = 0;
}
else
- nRes = (sal_uInt64) ImpRound( d );
+ nRes = (sal_uInt64) std::llround( d );
}
else if( n64 < 0 )
{
diff --git a/basic/source/sbx/sbxlng.cxx b/basic/source/sbx/sbxlng.cxx
index b173e8cc3d84..a5fcbadbad71 100644
--- a/basic/source/sbx/sbxlng.cxx
+++ b/basic/source/sbx/sbxlng.cxx
@@ -21,6 +21,8 @@
#include <basic/sbx.hxx>
#include "sbxconv.hxx"
+#include <cmath>
+
sal_Int32 ImpGetLong( const SbxValues* p )
{
SbxValues aTmp;
@@ -63,7 +65,7 @@ start:
SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = SbxMINLNG;
}
else
- nRes = (sal_Int32) ImpRound( p->nSingle );
+ nRes = (sal_Int32) std::lround( p->nSingle );
break;
case SbxSALINT64:
nRes = p->nInt64;
@@ -104,7 +106,7 @@ start:
SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = SbxMINLNG;
}
else
- nRes = (sal_Int32) ImpRound( dVal );
+ nRes = (sal_Int32) std::lround( dVal );
break;
}
case SbxBYREF | SbxSTRING:
@@ -127,7 +129,7 @@ start:
SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = SbxMINLNG;
}
else
- nRes = (sal_Int32) ImpRound( d );
+ nRes = (sal_Int32) std::lround( d );
}
break;
case SbxOBJECT: