On Thu, 14 Sep 2006 12:13:43 -0400, Ron Natalie <ro*@spamcop.net>
wrote in comp.lang.c++:
van6 wrote:
This question may a little stupid . But different books give different
answers.
No promotion occurs before the addition. The result of the addition is
still float. The conversion from float to double occurs when stored.
The reason why you may see difference of opinions is that C USED to
work differently.
So far, so good.
Any floating point operation was "logically"
expanded to double in the 1990 version of the C standard.
Nooooooooooo! ANSI C 89 and ISO C 90 both eliminated the automatic
conversion of floats to doubles in operations and as arguments in
calls to appropriately prototyped non-variadic functions.
C++ and
the 1999 C rewrote the promotion rules that don't widen floats to
doubles unless the other operand is a double.
Nope, you're thinking of pre standard K&R 1. No ANSI or ISO standard
for either C or C++ contained the widening, with the exception of
floats passed to the ... of a variadic function. And that widening
still occurs in both languages today.
In C, the widening still occurs when passing a float to a function
without a prototype in scope (which even C99 allows, although a
declaration specifying the return type is required). But that doesn't
apply to C++ at all, since all legal C++ function declarations are
what C calls prototypes.
--
Jack Klein
Home:
http://JK-Technology.Com
FAQs for
comp.lang.c
http://c-faq.com/
comp.lang.c++
http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html