Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!sdrc!thor!scjones From: scjones@thor.UUCP (Larry Jones) Newsgroups: comp.lang.c Subject: Re: Assinging values to type float Message-ID: <153@thor.UUCP> Date: 4 Sep 90 14:17:13 GMT References: <90240.003415RHMCSUPV@MIAMIU.BITNET> <11583@crdgw1.crd.ge.com> Organization: SDRC, Cincinnati Lines: 21 In article <11583@crdgw1.crd.ge.com>, volpe@underdog.crd.ge.com (Christopher R Volpe) writes: > This raises a question I've been wondering about for a while: When > we say that a float (or char) gets converted to a double (or int) in > an expression, what exactly constitutes an expression? Is a single > value on the RHS of an assignment operator an "expression" for > conversion purposes? Or is at least one operator required? If > I do a "f1=f2", does it first convert f2 to double and then back > to float in order to do the assignment? How about "c1=c2" for chars? An "expression" is defined by the C grammar. No operators are required, "i" is an expression as is "f1=f2" (note that "=" is the assignment >operator< in C). In fact "f1=f2" should cause f2 to be widened to double and then narrowed back to float. Fortunately, even very dump compilers are smart enough to optimize out the spurious widening and narrowing operations. ---- Larry Jones UUCP: uunet!sdrc!thor!scjones SDRC scjones@thor.UUCP 2000 Eastman Dr. BIX: ltl Milford, OH 45150-2789 AT&T: (513) 576-2070 Start tying the sheets together. We'll go out the window. -- Calvin