Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site ucla-cs.ARPA Path: utzoo!watmath!clyde!burl!ulysses!gamma!epsilon!zeta!sabre!petrus!bellcore!decvax!ittatc!dcdwest!sdcsvax!sdcrdcf!ucla-cs!jimc From: jimc@ucla-cs.UUCP Newsgroups: net.lang.c Subject: Re: Pointing Float Message-ID: <8104@ucla-cs.ARPA> Date: Wed, 18-Dec-85 12:49:42 EST Article-I.D.: ucla-cs.8104 Posted: Wed Dec 18 12:49:42 1985 Date-Received: Fri, 20-Dec-85 05:29:51 EST References: <689@brl-tgr.ARPA> Reply-To: jimc@ucla-cs.UUCP (Jim Carter) Organization: UCLA Computer Science Department Lines: 28 In article <689@brl-tgr.ARPA> cottrell@nbs-vms.arpa (COTTRELL, JAMES) writes: >/* >> > >> float a,b; >> > >> >> > >> a = b + 1.0; /* Gets done in double because 1.0 is a double. >> > >> Gag me with a spoon. */ > >One spoon coming up! > >> > > 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. > >> (3.5x>) and extensive related discussions for the last few days. The preliminary draft "C" standard X3J11/85-138 says in sect. B.1.2.3 (program execution) line 171 that the compiled code has to produce the same (sic) result as double precision, but needn't actually be double. Line 163 makes a similar statement about promoting char to int. By the way, it's hard to be sure that (float)x * (float)y == (float) ( (double)x * (double)y) down to the last bit in every pathological case, but in practice all we really need is that the answers differ less than an implementation-defined maximum, typically 1 least significant bit of float. How do people think about interpreting "same" in this way? James F. Carter (213) 206-1306 UCLA-SEASnet; 2567 Boelter Hall; 405 Hilgard Ave.; Los Angeles, CA 90024 UUCP:...!{ihnp4,ucbvax,{hao!cepu}}!ucla-cs!jimc ARPA:jimc@locus.UCLA.EDU