Say I have an a function:
- (void) doSomethingWithFloat:(float)aFloat;
and I call that function with a double precision floating point value as follows:
[self doSomethingWithFloat:12.0];
Is a conversion done from 12.0 (double) to 12.0f (single) at compile-time or runtime, or neither?
Just for clarity: I’m not asking for the difference between single precision and double
precision floating point numbers.
ObjectiveC actually follows most of C conventions – so floats are promoted to double per the C spec when passed to a function. The ObjectiveC compiler turns all methods into functions eventually, so your double works.
That said its best to turn on compiler warnings and pass CGFloats or floats – it just lets you know when you are losing precision.