Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site stcvax.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!hao!stcvax!rlr From: rlr@stcvax.UUCP (Roger Rose) Newsgroups: net.lang.c Subject: Re: C Floating point arithmetic Message-ID: <423@stcvax.UUCP> Date: Thu, 5-Dec-85 17:39:04 EST Article-I.D.: stcvax.423 Posted: Thu Dec 5 17:39:04 1985 Date-Received: Sat, 7-Dec-85 17:07:37 EST References: <1087@lll-crg.ARpA>, <4647@alice.UUCP> Organization: Storage Technology Corp. Louisville, CO Lines: 17 >> float a,b; >> >> a = b + 1.0; /* Gets done in double because 1.0 is a double. >> Gag me with a spoon. */ > > Nah, gets done in single because the compiler realizes that 1.0 has > the same representation in single and double, and therefore that > the result of the addition will be the same. Sorry, it get's done in double. ALL floats are converted to double prior to any operation. (Refer to K&R p. 41 on implicit type conversions.) -- Roger Rose UUCP: {hao ihnp4 decvax}!stcvax!rlr USnail: Storage Technology Corp. - MD 3T / Louisville, Co. 80028 phone: (303) 673-6873