Objective-C
Temel kaynak kodundan, CoreGraphics'te CGBase.h:
/* Definition of `CGFLOAT_TYPE', `CGFLOAT_IS_DOUBLE', `CGFLOAT_MIN', and
`CGFLOAT_MAX'. */
#if defined(__LP64__) && __LP64__
# define CGFLOAT_TYPE double
# define CGFLOAT_IS_DOUBLE 1
# define CGFLOAT_MIN DBL_MIN
# define CGFLOAT_MAX DBL_MAX
#else
# define CGFLOAT_TYPE float
# define CGFLOAT_IS_DOUBLE 0
# define CGFLOAT_MIN FLT_MIN
# define CGFLOAT_MAX FLT_MAX
#endif
/* Definition of the `CGFloat' type and `CGFLOAT_DEFINED'. */
typedef CGFLOAT_TYPE CGFloat;
#define CGFLOAT_DEFINED 1
Telif Hakkı (c) 2000-2011 Apple Inc.
Bu aslında şunları yapıyor:
#if defined(__LP64__) && __LP64__
typedef double CGFloat;
#else
typedef float CGFloat;
#endif
Burada __LP64__, mevcut mimarinin * 64 bit olup olmadığını gösterir.
32 bit sistemlerin hala 64 bit kullanabileceğini unutmayın, doublesadece daha fazla işlemci süresi gerektirir, bu nedenle CoreGraphics bunu uyumluluk için değil, optimizasyon amacıyla yapar. Performans konusunda endişe duymuyorsanız ancak doğruluk konusunda endişeleriniz varsa kullanın double.
hızlı
Swift yılında CGFloatbir olan structsarıcı etrafında ya Float32 bit mimarileri üzerinde veya Double64 bit olanlar (Sen ile çalıştırıcı veya derleme sırasında bu algılayabilir CGFloat.NativeType)
CoreGraphics kaynak kodu itibaren, içindeCGFloat.swift.gyb :
public struct CGFloat {
#if arch(i386) || arch(arm)
/// The native type used to store the CGFloat, which is Float on
/// 32-bit architectures and Double on 64-bit architectures.
public typealias NativeType = Float
#elseif arch(x86_64) || arch(arm64)
/// The native type used to store the CGFloat, which is Float on
/// 32-bit architectures and Double on 64-bit architectures.
public typealias NativeType = Double
#endif
* Özellikle, longs ve işaretçiler, dolayısıyla LP. Ayrıca bkz: http://www.unix.org/version2/whatsnew/lp64_wp.html