Re: Math.h functions with CGFloat
Re: Math.h functions with CGFloat
- Subject: Re: Math.h functions with CGFloat
- From: Quincey Morris <email@hidden>
- Date: Tue, 10 Aug 2010 10:44:06 -0700
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; 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?
If I'm at all correct, then using the 'float' versions of the math functions doesn't entirely eliminate (runtime) type conversions, and may introduce troubling precision issues in the order of conversions in an expression is not considered. Compiler optimization may mitigate some of this, but see http://ridiculousfish.com/blog/archives/2010/07/23/will-it-optimize/ for a salutary warning about naively believe in floating point optimization techniques.
Also, I remember we had a discussion on this list a few months ago concerning a warning flag that might have been 'Wshorten-64-to-32' or might have been something vaguely similar, where someone from Apple jumped in to say that using the warning *didn't* really make sense. I can't remember any more details, and I can't find the post in a quick search of the archives, but I mention it in case someone else has a better memory.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden