Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!ames!hc!hi!kurt From: kurt@hi.UUCP (Kurt Zeilenga) Newsgroups: comp.lang.c Subject: Re: Returning a value from ?: Message-ID: <7652@hi.UUCP> Date: Sat, 30-May-87 16:29:26 EDT Article-I.D.: hi.7652 Posted: Sat May 30 16:29:26 1987 Date-Received: Mon, 1-Jun-87 06:37:55 EDT References: <7555@brl-adm.ARPA> Reply-To: kurt@hi.UUCP (Kurt Zeilenga) Organization: U. of New Mexico, Albuquerque Lines: 30 In article <7555@brl-adm.ARPA> DAVE%UWF.BITNET@wiscvm.wisc.EDU writes: > >All, > Well, my recent probs with printf are solved, by linking with LCM >ahead of LC, as suggested. Thanks. > Next in line, I just (yesterday) got a copy of Turbo C, and was >trying out some old programs on it. It works mostly like a champ, but >I ran across a small bug. It goes like this: > > (f(a) * f(p) > 0) ? (a = p) : (b = p); > >with the function f() being defined elsewhere, and with all things being >defined as double. I got it to work by splitting up the ? : up into >an if ... else, but it worked w/o hitch under Lattice 3.0. Is the above By "worked" do you mean compiled or running with "proper" results. >statement not valid C code? The above statement is valid. However, beware of side effects and order of evaulation, you are not guaranteed the order of the evaulation of f(a) * f(p). Ie: some compilers may do f(a) first and then f(p), others may do f(p) first. K&R allows the compiler to rewrite such expressions. Could this be the root of the evil? Hope this helps.... -- Kurt Zeilenga (zeilenga@hc.dspo.gov) I want my talk.flame! "So long, Mom, I'm off to kill a commie..."