EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  <20032004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  <20032004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: Long expressions using MAX and MIN in CALC fields
From: Andrew Johnson <[email protected]>
To: Tim Mooney <[email protected]>
Cc: "Redman, Russell O." <[email protected]>, "Tech-Talk (E-mail)" <[email protected]>
Date: Thu, 27 Feb 2003 18:09:16 -0600
Tim Mooney wrote:

To this end, does anyone happen to know the precedence and associativity of these operators? I.e., does a + b <? c mean (a + b) <? c or a + (b <? c) does a <? b <? c mean (a <? b) <? c or a <? (b <? c) does a * b <? c mean (a * b) <? c or a * (b <? c) etc. I haven't been able to find this information online.

I've been doing some testing using g++ 3.2.2, here are my results:


Minimum operator <? precedence
------------------------------
a <? b * c means a <? (b * c)
a <? b + c means a <? (b + c)
a <? b << c means a <? (b << c)
a <? b < c means a <? (b < c)
a <? b == c means a <? (b == c)
a <? b & c means (a <? b) & c
a <? b ^ c means (a <? b) ^ c

Which inserts <? between == and & on the precedence table. Also:

a == b <? c means (a == b) <? c
a & b <? c means a & (b <? c)

shows that <? isn't on the same line as either == or &.

Maximum operator >? precedence
------------------------------
a >? b == c means a >? (b == c)
a >? b & c means (a >? b) & c
a == b >? c means (a == b) >? c
a & b >? c means a & (b >? c)

So this also fits between == and & and is not on the same line as either.

Relative precedence and associativity
-------------------------------------
a >? b <? c means (a >? b) <? c
a <? b >? c means (a <? b) >? c

Thus the two have the same precedence, and are left-to-right associative.

This confirms experimentally the result that Noboru found by looking at the g++ source code.

- Andrew
--
Tongue-twister: Say "Peggy Babcock" 10 times without stumbling...


Replies:
Re: Long expressions using MAX and MIN in CALC fields Tim Mooney
References:
Long expressions using MAX and MIN in CALC fields Redman, Russell O.
Re: Long expressions using MAX and MIN in CALC fields Andrew Johnson
Re: Long expressions using MAX and MIN in CALC fields Tim Mooney

Navigate by Date:
Prev: Re: Long expressions using MAX and MIN in CALC fields Noboru Yamamoto
Next: GPIB Driver for SCPI commands to an Ethernet device like Keithley 2701 Multimeter Allison, Stephanie
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  <20032004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: Long expressions using MAX and MIN in CALC fields Noboru Yamamoto
Next: Re: Long expressions using MAX and MIN in CALC fields Tim Mooney
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  <20032004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 10 Aug 2010 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·