Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!taumet!steve From: steve@taumet.com (Stephen Clamage) Newsgroups: comp.lang.c Subject: Re: Assinging values to type float Message-ID: <444@taumet.com> Date: 4 Sep 90 18:23:06 GMT References: <90240.003415RHMCSUPV@MIAMIU.BITNET> <667.26da7736@iccgcc.decnet.ab.com> <11394@crdgw1.crd.ge.com> <1258@kubix.kub.nl> <11583@crdgw1.crd.ge.com> Organization: Taumetric Corporation, San Diego Lines: 23 volpe@underdog.crd.ge.com (Christopher R Volpe) writes: |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? In C, assignment is not necessarily a statement, as in some other languages. Assignment is accomplished by the '=' operator, and the assignment is an expression like any other. Section 3.3.16 (and its subsections) describe precisely what happens. Briefly, the value of the rhs is converted to the type of the lhs and the assignment is performed. As to whether multiple conversions are performed, the "as-if" rule applies. In principle, integral promotions and other specified conversions are performed (e.g., char to int) and the result converted to the type of the lhs. If this turns out to be identical in result to just copying the value, it is sufficient to copy the value. -- Steve Clamage, TauMetric Corp, steve@taumet.com