3 ms·
Point 5 seems like dangerous advice, shortening types (especially floating-point types) without analysis isn't a good idea and especially not a deadly sin. Cha
by jensnockert 14y ago
Point 5 seems like dangerous advice, shortening types (especially floating-point types) without analysis isn't a good idea and especially not a deadly sin.
Changing doubles to floats can give a significant performance boost (mainly on ARM with Neon) but it brings significant limitations on range and accuracy that can lead to subtle bugs if you don't do the analysis (especially if you mostly test it with double precision.)
- stephencanon 14y agoVery much this. Using floating-point types that have different sizes on different platforms without detailed analysis of the algorithm is a recipe for hard-to-diagnose bugs. Use float, or use double, whichever is most appropriate. There are some subtle historical reasons why CGFloat is defined the way it is; a reasonable argument could be made that it "should have" been double on all platforms with 20/20 hindsight, but it can't be changed now without breaking binary compatibility.