I'm converting an app to work in 64-bit. The Apple docs state that the CGFloat
type is a float
on 32-bit and a double
on 64-bit.
If that is so, how do you handle encoding/decoding of the value? For instance, if creating an NSNumber
from a CGFloat
, should I use the -numberWithFloat:
or -numberWithDouble:
method of NSNumber? The same question applies to the NSCoder
and NSKeyedArchiver
methods -encodeFloat:forKey:
and -encodeDouble:forKey:
.
Do I have to write a conditional macro so that -numberWithFloat:
is called on 32-bit and -numberWithDouble:
on 64-bit?
What happens if a user running the 64-bit version of the app saves a file where these values are encoded as doubles and the file is opened/unarchived on a 32-bit system?
All the methods in my app that use CGFloats
are unlikely to ever need the precision level of a double
, so should I even be worrying about this?