4df Subj : Re: Any help on why? To : borland.public.cpp.borlandcpp From : waking Date : Fri Jul 09 2004 12:24 am On Thu, 08 Jul 2004 10:52:01 -0700, Bob Gonder wrote: >>Floats are 32 bits in both DOS (16-bit) and Windows (32-bit). >>Doubles are 64 bits in both DOS (16-bit) and Windows (32-bit). >Then why does the compiler (BCB and apparently BC5.02) push 8 bytes >when passing a float? >Maybe all floats are passed as doubles? In the printf function, floats are automatically promoted to doubles. That's the reason the "l" (lower case L) size modifier is not needed together with %f when passing doubles. By contrast, the scanf function *does* need %lf for doubles as no promotion occurs. See the C FAQ at http://www.eskimo.com/~scs/C-faq/faq.html especially: "12.9: Someone told me it was wrong to use %lf with printf(). How can printf() use %f for type double, if scanf() requires %lf?" "12.13: Why doesn't this code: double d; scanf("%f", &d); work?" "15.2: How can %f be used for both float and double arguments in printf()? Aren't they different types?" -- Wayne A. King (waking@idirect.com, Wayne_A_King@compuserve.com) . 0