The information in this article applies to:
SUMMARY
When passing arguments of type float to a function that accepts a variable
number of arguments, those floats not explicitly declared in the prototype
will be promoted to type double.
MORE INFORMATION
The sample program below returns the sum of a variable list of floating-
point values. The sum returned is not correct because the variables of type
float (other than the float that was declared) are promoted to double, but
are treated as floats by va_start and va_arg.
If the expression that denotes the called function has a type that does not include a prototype, the integral promotions are performed on each argument and arguments that have type float are promoted to double. These are called the default argument promotions. . . . If the expression that denotes the called function has a type that includes a prototype, the arguments are implicitly converted to the types of the corresponding parameters. The ellipsis notation in a function prototype declarator causes argument type conversion to stop after the last declared parameter. The default argument promotions are performed on trailing arguments.To work around this situation, use doubles instead of floats for values that will be passed to functions that accept a variable number of arguments. Sample Code
Possible Program Output
Additional query words:
Keywords : kbcode kbLangC kbVC100 kbVC150 kbVC200 kbVC400 kbVC500 kbVC600 |
Last Reviewed: July 1, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |