openoffice-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mathias Röllig <mroellig.n...@gmx.net>
Subject [API] Priority Problem with AND and OR
Date Mon, 12 Oct 2015 19:40:13 GMT
Hello!

I stumbled into a priority problem with the boolean operators AND and 
OR. I cannot find any documentation for this.

First mathematical examples.

With
MsgBox( 3 * 2 ^ 2 )
you will see, that ^ has a higher priority than *.
(2 ^ 2) = 4
4 * 3 = 12
With
MsgBox( (3 * 2) ^ 2 )
you will get the right result 6 ^ 2 = 36.

With
MsgBox( 3 + 4 * 3 )
you will see, that * has a higher priority than +.
(4 * 3) = 12
3 * 12 = 36
With
MsgBox( (3 + 4) * 3 )
you will get the right result 7 * 3 = 21.

Now looking at the same logic with logical operators.

Dim bResult As Boolean
bResult = TRUE Or FALSE And TRUE
MsgBox( bResult )
bResult = TRUE Or TRUE And FALSE
MsgBox( bResult )

What do you expect?
For logical operations AND is equivalent to * and OR is equivalent to +.
AND should have a higher priority than OR, so I would expect in both 
cases (because TRUE Or (<anything>) = TRUE):
bResult = TRUE
But you will get
TRUE Or FALSE And TRUE = (TRUE Or FALSE) And TRUE = TRUE
TRUE Or TRUE And FALSE = (TRUE Or TRUE) And FALSE = FALSE

Is there any explanation that AND and OR have (and should have) the same 
priority?

Regards, Mathias

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@openoffice.apache.org
For additional commands, e-mail: dev-help@openoffice.apache.org


Mime
View raw message