Bug 128870 - VBAsupport - Unary minus ('-') precedence over '^'
Summary: VBAsupport - Unary minus ('-') precedence over '^'
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-11-18 10:53 UTC by andrecbarros
Modified: 2024-09-01 07:02 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description andrecbarros 2019-11-18 10:53:41 UTC
Description:
The unary minus ('-') is taking precedence over exponentiation ('^') on basic (vb?) evaluation.

To see it, create a macro module and insert:
-(1#/2)^2
on it.

The result value will be 0.25. On Excel it gives -0.25.


Steps to Reproduce:
1. Insert "somevar = -(1#/2)^2" inside a macro module
2. eval it.
3.

Actual Results:
0.25

Expected Results:
-0.25


Reproducible: Always


User Profile Reset: No



Additional Info:
Comment 1 Srirupa 2019-11-26 05:39:30 UTC
Hi
Thank you for reporting the issue.I can confirm that the issue is present in the below version.

Version: 6.3.2.2
Build ID: 98b30e735bda24bc04ab42594c85f7fd8be07b9c
CPU threads: 4; OS: Mac OS X 10.13.4; UI render: default; VCL: osx; 
Locale: en-US (en_US.UTF-8); UI-Language: en-US
Calc: threaded

The below VBA macro in Libre gives the result as 0.25 , whereas in MS Excel it gives the result as -0.25 

REM  *****  BASIC  *****

Sub Main
DIM Variable_One As Double
Variable_One=-(1#/2)^2
MsgBox Variable_One
End Sub

Thanks
Srirupa
Comment 2 Xisco Faulí 2019-12-02 16:21:19 UTC
Also reproduced in

LibreOffice 3.3.0 
OOO330m19 (Build:6)
tag libreoffice-3.3.0.4
Comment 3 QA Administrators 2022-09-01 03:48:02 UTC Comment hidden (obsolete)
Comment 4 QA Administrators 2024-09-01 03:15:55 UTC Comment hidden (obsolete)
Comment 5 fpy 2024-09-01 07:02:22 UTC
'-' precedence is consitant with ODF, see e.g. https://ask.libreoffice.org/t/operator-precedence-in-calc-any-overview/92393/2

Seems to be VBA specific, so the test case should include : Option VBASupport 1