Float comparison (equality) in CoreGraphics
问题 Apple CoreGraphics.framework , CGGeometry.h : CG_INLINE bool __CGSizeEqualToSize(CGSize size1, CGSize size2) { return size1.width == size2.width && size1.height == size2.height; } #define CGSizeEqualToSize __CGSizeEqualToSize Why do they (Apple) compare floats with == ? I can't believe this is a mistake. So can you explain me? (I've expected something like fabs(size1.width - size2.width) < 0.001 ). 回答1: Floating point comparisons are native width on all OSX and iOS architectures. For float ,