Path: utzoo!utgpu!watserv1!watmath!att!cbnewsl!clyde!feg From: feg@clyde.ATT.COM (Forrest Gehrke,2C-119,7239,ATTBL) Newsgroups: comp.lang.c Subject: Conditional/ternary Statement Keywords: The third attempt!! Message-ID: <4014@cbnewsl.ATT.COM> Date: 7 Feb 90 18:38:27 GMT Sender: nntp@cbnewsl.ATT.COM Reply-To: feg@clyde.ATT.COM Distribution: na Organization: AT&T Bell Laboratories Lines: 22 OK, sorry people. I will get my example statement right, perhaps on the third attempt (:-<) Maybe I have answered my own question: the thing is too messy to write!! Now suppose one were sorting among unsigned ints from 0 to 4. Would this be kosher? #define Srt(x) ((x)==0 ? 0 : (x) < 2 ? 1 : (x) < 3 ? 2 : (x) < 4 ? 3 : 4) It would seem to be valid, but only if exited immediately at the first true test. If kosher, are there any speed advantages over a series of if-else, or case statements? (I realize that a pitfall might occur if the value range of the tested variables were less than zero or more than 4--this is just a conjured example and is really a question whether multiple ternary operators may be used in a single statement). Forrest Gehrke feg@clyde.ATT.COM