diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2015-02-24 23:02:24 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2015-04-30 14:32:50 +0000 |
commit | b51a30504ec3c00b0bad616817471aa01918e06e (patch) | |
tree | 4b71f842938dd606f1b9ec63071be198c38b53a1 | |
parent | c9e0d9f57993a07bc4f03d922930cef2be7f9b69 (diff) |
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>
(cherry picked from commit 0f79a5ff07e5b392044726b657998561cbe97fda)
Reviewed-on: https://gerrit.libreoffice.org/15576
-rw-r--r-- | basic/source/comp/exprnode.cxx | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/basic/source/comp/exprnode.cxx b/basic/source/comp/exprnode.cxx index 4340848bf66e..140074ef9517 100644 --- a/basic/source/comp/exprnode.cxx +++ b/basic/source/comp/exprnode.cxx @@ -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; |