On Feb 9, 2009, at 11:04 AM, Sean McBride wrote:

I agree with the OP that CGFloat is very annoying in this respect.  My
solution has been to use the 'f' suffix for constants.

The problem with that is, if you do a mathematical operation on a double using a float (including constants), you will lose a little precision, which does not happen when you stick strictly to doubles. If losing precision is not important, though, then I guess that's OK.

That's why I think the two best solutions to this problem are:
1. Cast double constants to CGFloat
2. Write all constants as doubles, and build your 32-bit code with the -fsingle-precision-constant flag

(2) is my favorite since it's easier and less messy.

Similarly, there
is no CGFloat version of sin() and other math functions.


Yeah, I solved that one by using macros, like this: (typed in Mail but should work)

#if CGFLOAT_IS_DOUBLE == 1
#define MyCGFloatSin(x) sin(x)
#else
#define MyCGFloatSin(x) sinf(x)
#endif

Nick Zitzmann
<http://www.chronosnet.com/>

_______________________________________________

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

Reply via email to