I noticed the following in a chunk of code I’m maintaining/extending:
float systemVersion = [[[UIDevice currentDevice] systemVersion] floatValue];
if (systemVersion > 3.2 || systemVersion == 3.2 ) {
//Stuff
}
I know floating point can result in some odd comparison behaviors due to precision, but would the above behave any differently than the chunk of code below?
float systemVersion = [[[UIDevice currentDevice] systemVersion] floatValue];
if (systemVersion >= 3.2) {
//Stuff
}
It’s the same thing. In many compilers, the resulting machine instructions are exactly the same (although I can’t say for sure that’s true for clang).