Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site brl-tgr.ARPA Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxt!houxm!whuxl!whuxlm!akgua!gatech!seismo!brl-tgr!tgr!cottrell@nbs-vms.arpa From: cottrell@nbs-vms.arpa (COTTRELL, JAMES) Newsgroups: net.lang.c Subject: Pointing Float Message-ID: <689@brl-tgr.ARPA> Date: Sat, 14-Dec-85 12:58:47 EST Article-I.D.: brl-tgr.689 Posted: Sat Dec 14 12:58:47 1985 Date-Received: Mon, 16-Dec-85 05:12:51 EST Sender: news@brl-tgr.ARPA Lines: 41 /* > > >> 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. Try as I might, I could not generate any single precision instruxions. I even tried stuff like `a += 1.0' and `a++'. Would that `twere so. > > 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.) Agreed. But beware of the word `implicit'. Normally char's & short's get promoted to int's even when combined with themselves, but using the `++', `--', or `op=' forms will do the operation entirely in the shorter length. This is/was a big concern of some implementations of C on say, a z80, where one does not want to extend a char to an int just to mask it with the constant 037. > I really wish people would NOT POST if they don't know what > they're talking about. Andy Koenig, as usual, gave a correct > answer and some turkey, as usual, contradicts him. Sheesh. I couldn't agree more with the intent of this statement. People, before posting, *ask the machine* after you RTFM. Unfortunately, you picked the wrong time to post that. Andy is usually right, but not this time. (Well maybe he is if he has something other than a 4.2 BSD VAX). I agree he *should* be. But I think you owe some turkey an apology and are left eating crow. jim cottrell@nbs */ ------