On Tue, Aug 10, 2010 at 1:44 PM, Quincey Morris <quinceymor...@earthlink.net> wrote: > Excuse me for jumping into this discussion with half a brain, but isn't there > another consideration? > > I was under the impression that C does not have symmetric support for > 'double' and 'float'. Specifically, I thought that any (a) expression > involving floating point numbers promoted everything to doubles to apply the > operators to;
All operators with floating-point arguments must be performed with double precision. However, the C spec operates according to the "as-if" rule. The compiler is free to generate ANY code it wishes so long as the result is the same "as if" it were performed as the spec dictates. So in short, as long as your CPU's FPU does accurate 32-bit float calculations (and they usually do), the compiler can take something like this: floata = floatb * floatc; And compile it into code that does not ever promote to double, and still adhere to the standard. > and (b) 'float' values passed as function arguments are actually passed as > doubles. (Or is it that there are no 'float' expressions, only 'double' > expressions?) (Isn't that why it's safe to put 'float's in variable argument > lists without casting them to 'double'?) Is this just something I dreamed, or > is there something in the C language spec that's relevant? It's sort of half and half. Floats are promoted to doubles *when passed as a variable argument to a function that takes varargs*. They are not promoted when passing to a normal, non-variable argument function, unless of course the function takes 'double' for that parameter. So in the vast majority of cases, passing a float to a function that takes a float will not result in promotion to double. Mike _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com