[Libreoffice-commits] core.git: sc/source
Eike Rathke (via logerrit)
logerrit at kemper.freedesktop.org
Mon May 3 17:40:14 UTC 2021
sc/source/core/tool/interpr6.cxx | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
New commits:
commit 9a71644aa475a6090f60a8b90665116b98851b9c
Author: Eike Rathke <erack at redhat.com>
AuthorDate: Mon May 3 17:07:39 2021 +0200
Commit: Eike Rathke <erack at redhat.com>
CommitDate: Mon May 3 19:39:33 2021 +0200
RAWSUBTRACT() process arguments from left to right
RAWSUBTRACT(1;2;3;4) calculated 1-4-3-2, popping from stack.
Reverse stack to calculate 1-2-3-4 in "natural" left to right
order.
That may make a difference like in
=RAWSUBTRACT(0.3;0.2;0.1;-0.1;-0.2;0.3)
where the result was 2.77555756156289E-17
(0.3-0.3--0.2--0.1-0.1-0.2) == (0.0--0.2--0.1-0.1-0.2)
same as =RAWSUBTRACT(0;0.2;0.1;-0.1;-0.2)
and now is 0
(0.3-0.2-0.1--0.1--0.2-0.3)
but =RAWSUBTRACT(0;0.2;0.1;-0.1;-0.2)
now is -2.77555756156289E-17
Change-Id: If00d88e3d3d1944a3d9a6b4576b773afe9cbd294
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115047
Reviewed-by: Eike Rathke <erack at redhat.com>
Tested-by: Jenkins
diff --git a/sc/source/core/tool/interpr6.cxx b/sc/source/core/tool/interpr6.cxx
index a48d7d3ad77b..0e2824ef1f2e 100644
--- a/sc/source/core/tool/interpr6.cxx
+++ b/sc/source/core/tool/interpr6.cxx
@@ -995,17 +995,15 @@ void ScInterpreter::ScRawSubtract()
if (!MustHaveParamCountMin( nParamCount, 2))
return;
- // Fish the 1st parameter from the stack and push it on top.
- const FormulaToken* p = pStack[ sp - nParamCount ];
- PushWithoutError( *p );
+ // Reverse stack to process arguments from left to right.
+ ReverseStack( nParamCount);
// Obtain the minuend.
double fRes = GetDouble();
- while (nGlobalError == FormulaError::NONE && nParamCount > 1)
+ while (nGlobalError == FormulaError::NONE && --nParamCount > 0)
{
// Simple single values without matrix support.
fRes -= GetDouble();
- --nParamCount;
}
while (nParamCount-- > 0)
PopError();
More information about the Libreoffice-commits
mailing list