[prev in list] [next in list] [prev in thread] [next in thread]
List: freebsd-hackers
Subject: Re: cc/gcc
From: Richard Neswold <neswold () aduxb ! fnal ! gov>
Date: 1997-05-30 17:20:10
[Download RAW message or body]
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
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic