Kaydet (Commit) 3db1e9ed authored tarafından Arnaud Versini's avatar Arnaud Versini Kaydeden (comit) Julien Nabet

BASIC : remove ImpRound and use std::(l)lround instead

Change-Id: I1e8f58890395bc6bc29f56c258836db3dc52384c
Reviewed-on: https://gerrit.libreoffice.org/30464Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarJulien Nabet <serval2412@yahoo.fr>
üst 4bcf1872
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
#include <basic/sbx.hxx> #include <basic/sbx.hxx>
#include "sbxconv.hxx" #include "sbxconv.hxx"
#include <cmath>
sal_uInt8 ImpGetByte( const SbxValues* p ) sal_uInt8 ImpGetByte( const SbxValues* p )
{ {
SbxValues aTmp; SbxValues aTmp;
...@@ -121,7 +123,7 @@ start: ...@@ -121,7 +123,7 @@ start:
SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = 0; SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = 0;
} }
else else
nRes = (sal_uInt8) ImpRound( p->nSingle ); nRes = (sal_uInt8) std::lround( p->nSingle );
break; break;
case SbxDATE: case SbxDATE:
case SbxDOUBLE: case SbxDOUBLE:
...@@ -147,7 +149,7 @@ start: ...@@ -147,7 +149,7 @@ start:
SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = 0; SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = 0;
} }
else else
nRes = (sal_uInt8) ImpRound( dVal ); nRes = (sal_uInt8) std::lround( dVal );
break; break;
} }
case SbxBYREF | SbxSTRING: case SbxBYREF | SbxSTRING:
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
#include <basic/sbx.hxx> #include <basic/sbx.hxx>
#include "sbxconv.hxx" #include "sbxconv.hxx"
#include <cmath>
sal_Unicode ImpGetChar( const SbxValues* p ) sal_Unicode ImpGetChar( const SbxValues* p )
{ {
SbxValues aTmp; SbxValues aTmp;
...@@ -109,7 +111,7 @@ start: ...@@ -109,7 +111,7 @@ start:
SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = SbxMINCHAR; SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = SbxMINCHAR;
} }
else else
nRes = (sal_Unicode) ImpRound( p->nSingle ); nRes = (sal_Unicode) std::lround( p->nSingle );
break; break;
case SbxDATE: case SbxDATE:
case SbxDOUBLE: case SbxDOUBLE:
...@@ -135,7 +137,7 @@ start: ...@@ -135,7 +137,7 @@ start:
SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = SbxMINCHAR; SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = SbxMINCHAR;
} }
else else
nRes = (sal_uInt8) ImpRound( dVal ); nRes = (sal_uInt8) std::lround( dVal );
break; break;
} }
case SbxBYREF | SbxSTRING: case SbxBYREF | SbxSTRING:
...@@ -156,7 +158,7 @@ start: ...@@ -156,7 +158,7 @@ start:
SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = SbxMINCHAR; SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = SbxMINCHAR;
} }
else else
nRes = (sal_Unicode) ImpRound( d ); nRes = (sal_Unicode) std::lround( d );
} }
break; break;
case SbxOBJECT: case SbxOBJECT:
......
...@@ -37,8 +37,7 @@ void ImpGetIntntlSep( sal_Unicode& rcDecimalSep, sal_Unicode& rcThousandSep ); ...@@ -37,8 +37,7 @@ void ImpGetIntntlSep( sal_Unicode& rcDecimalSep, sal_Unicode& rcThousandSep );
// SBXINT.CXX // SBXINT.CXX
double ImpRound( double ); sal_Int16 ImpGetInteger( const SbxValues* );
sal_Int16 ImpGetInteger( const SbxValues* );
void ImpPutInteger( SbxValues*, sal_Int16 ); void ImpPutInteger( SbxValues*, sal_Int16 );
sal_Int64 ImpGetInt64( const SbxValues* ); sal_Int64 ImpGetInt64( const SbxValues* );
......
...@@ -21,10 +21,7 @@ ...@@ -21,10 +21,7 @@
#include <basic/sbx.hxx> #include <basic/sbx.hxx>
#include "sbxconv.hxx" #include "sbxconv.hxx"
double ImpRound( double d ) #include <cmath>
{
return d + ( d < 0 ? -0.5 : 0.5 );
}
sal_Int16 ImpGetInteger( const SbxValues* p ) sal_Int16 ImpGetInteger( const SbxValues* p )
{ {
...@@ -84,7 +81,7 @@ start: ...@@ -84,7 +81,7 @@ start:
SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = SbxMININT; SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = SbxMININT;
} }
else else
nRes = (sal_Int16) ImpRound( p->nSingle ); nRes = (sal_Int16) std::lround( p->nSingle );
break; break;
case SbxCURRENCY: case SbxCURRENCY:
{ {
...@@ -145,7 +142,7 @@ start: ...@@ -145,7 +142,7 @@ start:
SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = SbxMININT; SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = SbxMININT;
} }
else else
nRes = (sal_Int16) ImpRound( dVal ); nRes = (sal_Int16) std::lround( dVal );
break; break;
} }
case SbxLPSTR: case SbxLPSTR:
...@@ -168,7 +165,7 @@ start: ...@@ -168,7 +165,7 @@ start:
SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = SbxMININT; SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = SbxMININT;
} }
else else
nRes = (sal_Int16) ImpRound( d ); nRes = (sal_Int16) std::lround( d );
} }
break; break;
case SbxOBJECT: case SbxOBJECT:
...@@ -350,7 +347,7 @@ sal_Int64 ImpDoubleToSalInt64( double d ) ...@@ -350,7 +347,7 @@ sal_Int64 ImpDoubleToSalInt64( double d )
SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = SbxMINSALINT64; SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = SbxMINSALINT64;
} }
else else
nRes = (sal_Int64) ImpRound( d ); nRes = (sal_Int64) std::llround( d );
return nRes; return nRes;
} }
...@@ -366,7 +363,7 @@ sal_uInt64 ImpDoubleToSalUInt64( double d ) ...@@ -366,7 +363,7 @@ sal_uInt64 ImpDoubleToSalUInt64( double d )
SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = 0; SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = 0;
} }
else else
nRes = (sal_uInt64) ImpRound( d ); nRes = (sal_uInt64) std::llround( d );
return nRes; return nRes;
} }
...@@ -716,7 +713,7 @@ start: ...@@ -716,7 +713,7 @@ start:
SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = 0; SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = 0;
} }
else else
nRes = (sal_uInt64) ImpRound( d ); nRes = (sal_uInt64) std::llround( d );
} }
else if( n64 < 0 ) else if( n64 < 0 )
{ {
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
#include <basic/sbx.hxx> #include <basic/sbx.hxx>
#include "sbxconv.hxx" #include "sbxconv.hxx"
#include <cmath>
sal_Int32 ImpGetLong( const SbxValues* p ) sal_Int32 ImpGetLong( const SbxValues* p )
{ {
SbxValues aTmp; SbxValues aTmp;
...@@ -63,7 +65,7 @@ start: ...@@ -63,7 +65,7 @@ start:
SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = SbxMINLNG; SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = SbxMINLNG;
} }
else else
nRes = (sal_Int32) ImpRound( p->nSingle ); nRes = (sal_Int32) std::lround( p->nSingle );
break; break;
case SbxSALINT64: case SbxSALINT64:
nRes = p->nInt64; nRes = p->nInt64;
...@@ -104,7 +106,7 @@ start: ...@@ -104,7 +106,7 @@ start:
SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = SbxMINLNG; SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = SbxMINLNG;
} }
else else
nRes = (sal_Int32) ImpRound( dVal ); nRes = (sal_Int32) std::lround( dVal );
break; break;
} }
case SbxBYREF | SbxSTRING: case SbxBYREF | SbxSTRING:
...@@ -127,7 +129,7 @@ start: ...@@ -127,7 +129,7 @@ start:
SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = SbxMINLNG; SbxBase::SetError( ERRCODE_SBX_OVERFLOW ); nRes = SbxMINLNG;
} }
else else
nRes = (sal_Int32) ImpRound( d ); nRes = (sal_Int32) std::lround( d );
} }
break; break;
case SbxOBJECT: case SbxOBJECT:
......
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