Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!mcgill-vision!snorkelwacker!bloom-beacon!eru!hagbard!sunic!dkuug!iesd!iesd.auc.dk!richard From: richard@iesd.auc.dk (Richard Flamsholt S0rensen) Newsgroups: comp.lang.c Subject: Re: Nasty bug Message-ID: Date: 12 Sep 90 18:27:18 GMT References: <2020@engage.enet.dec.com> <6441@wolfen.cc.uow.oz> <26350@mimsy.umd.edu> Sender: news@iesd.auc.dk (UseNet News) Organization: Mathematics and Computer Science, University of Aalborg Lines: 33 In-reply-to: chris@mimsy.umd.edu's message of 4 Sep 90 16:05:33 GMT In article <26350@mimsy.umd.edu> chris@mimsy.umd.edu (Chris Torek) writes: > In article richard@iesd.auc.dk > (Richard Flamsholt S0rensen) writes: > > Nope. ANSI states, that floats remain floats unless the expression > >contains more precise types, that is long double or double, in which > >case the float in converted. > > This is *almost* right. The ANSI C standard does not say that a > compiler cannot do `float f = 0.1; f += f;' as `convert f to double; > add double to double; convert result to float', but it does give > the compiler the option of doing it as `add float to float'. Ooops - you're right: I'm wrong. Sure, optimizing is always legal. > >Therefore, if the float is the only parameter to a function it is > >*not* converted to a double in the expression, regardless of how the > >function was declared. > > This, however, is almost completely wrong. No, but I should have emphazied my point. The original poster claimed, that the float was converted, because it was part of an expression and, as he said, "-in expressions, floats are always converted to doubles". My objection to this was, that it isn't *the expression* which converts the float - it's the fact, that said expression is an argument to a function, which might convert it. Unfortunately, that point were lost in the function-business ... -- /Richard Flamsholt richard@iesd.auc.dk