Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 May 1997 12:20:10 -0500 (CDT)
From:      Richard Neswold <neswold@aduxb.fnal.gov>
To:        Thomas David Rivers <ponds!rivers@dg-rtp.dg.com>
Cc:        FreeBSD-Hackers <hackers@hub.freebsd.org>
Subject:   Re: cc/gcc
Message-ID:  <Pine.GSO.3.95.970530121029.21648A-100000@aduxb.fnal.gov>
In-Reply-To: <199705301200.IAA11334@lakes.water.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 30 May 1997, Thomas David Rivers wrote:

>  I believe '?' has a higher precedence than '=='; so you are really
> saying: 

Nope. "==" has higher precedence than "?:". Furthermore, '==' is
left-to-right associative. 

> >      a = 1; b = 1; c = 0;
> >      c = a == b ==  1  ?  1  :  0 ; printf(" %i\n", c);

Using parenthesis to indicate the precedence:

c = (((a == b) == 1) ? 1 : 0);
    (( 1       == 1) ? 1 : 0);
    ( 1              ? 1 : 0);
    1;  

> >      a='1'; b='1'; c = 0;
> >      c = a == b == '1' ? '1' : '0'; printf(" %c\n", c);

c = (((a == b) == '1') ? '1' : '0');
    (( 1       == '1') ? '1' : '0');
    ( 0                ? '1' : '0');
    '0';

  Rich

 ------------------------------------------------------------------------
  Richard Neswold, Accelerator Div./Controls Dept |     neswold@fnal.gov
  Fermilab, PO Box 500, MS 347, Batavia, IL 60510 | voice (630) 840-3454
  'finger neswold@aduxb.fnal.gov' for PGP key     |   fax (630) 840-3093





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.3.95.970530121029.21648A-100000>