tdf#84435: Mod operator does not deal with decimals as described in help

Change-Id: I8dbfdf4bb2eceac0b5afbddd3f35e1dcde2db68b
Reviewed-on: https://gerrit.libreoffice.org/14611
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
This commit is contained in:
Julien Nabet
2015-02-24 23:02:24 +01:00
committed by Eike Rathke
parent 3d69f625fc
commit 0f79a5ff07

View File

@@ -320,9 +320,9 @@ void SbiExprNode::FoldConstants()
else if( nl < SbxMINLNG ) err = true, nl = SbxMINLNG;
if( nr > SbxMAXLNG ) err = true, nr = SbxMAXLNG;
else if( nr < SbxMINLNG ) err = true, nr = SbxMINLNG;
ll = (long) nl; lr = (long) nr;
llMod = (long) (nl < 0 ? nl - 0.5 : nl + 0.5);
lrMod = (long) (nr < 0 ? nr - 0.5 : nr + 0.5);
ll = static_cast<long>(nl); lr = static_cast<long>(nr);
llMod = static_cast<long>(nl);
lrMod = static_cast<long>(nr);
if( err )
{
pGen->GetParser()->Error( SbERR_MATH_OVERFLOW );
@@ -387,7 +387,7 @@ void SbiExprNode::FoldConstants()
{
pGen->GetParser()->Error( SbERR_ZERODIV ); nVal = HUGE_VAL;
bError = true;
} else nVal = llMod % lrMod;
} else nVal = llMod - lrMod * (llMod/lrMod);
eType = SbxLONG; break;
case AND:
nVal = (double) ( ll & lr ); eType = SbxLONG; break;