CGFloat-based math functions? CGFloat-based math functions? ios ios

CGFloat-based math functions?


Edit: So this question is no longer theoretical now that we have 64-bit iOS!

I think the easiest way to deal with this is to use tgmath.h, instead of math.h (math.h gets imported by Cocoa automatically, tgmath doesn't so you'll need to declare it somewhere).

There are a number of potential solutions discussed at the Cocoa mailing list thread:http://www.cocoabuilder.com/archive/cocoa/291802-math-functions-with-cgfloat.html

I would agree with the majority of people on that list that tgmath is probably the way to go. I believe it was originally intended to allow easy porting of Fortran code, but it also works in this scenario. TGMath will let you do:

double floor(double x);float floor(float x);long double floor(long double x);


matomo