openoffice-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rory O'Farrell <ofarr...@iol.ie>
Subject Re: [API] Priority Problem with AND and OR
Date Mon, 12 Oct 2015 19:58:39 GMT
On Mon, 12 Oct 2015 15:45:16 -0400
Andrew Pitonyak <andrew@pitonyak.org> wrote:

> Yes, I note this travesty in OOME. There is also a difference in the 
> way that it handles exponentiation. Standard rules indicate that 2^3^4 
> is evaluated as 2^(3^4) rather than (2^3)^4, wihch is what OOo does.

This problem came up recently several times on the en-Forum; we advised that it is best to
use the brackets to define order of calculation (particularly as so many Calc users are mathematically
inexperienced).  It would nevertheless be good to have the matter correct in some revision.

Rory O'Farrell 
> On 12.10.2015 15:40, Mathias Röllig wrote:
> > 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
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@openoffice.apache.org
> For additional commands, e-mail: dev-help@openoffice.apache.org
> 
> 


-- 
Rory O'Farrell <ofarrwrk@iol.ie>

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


Mime
View raw message