Nasty bug

Richard Flamsholt S0rensen richard at iesd.auc.dk
Thu Sep 13 04:27:18 AEST 1990


In article <26350 at mimsy.umd.edu> chris at mimsy.umd.edu (Chris Torek) writes:
> In article <RICHARD.90Sep3115406 at orange.iesd.auc.dk> richard at iesd.auc.dk
> (Richard Flamsholt S0rensen) <that's me> 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 at iesd.auc.dk



More information about the Comp.lang.c mailing list