Floating point compared s> = versus (> or ==)

I noticed the following in a piece of code that I support / extend:

float systemVersion = [[[UIDevice currentDevice] systemVersion] floatValue]; if (systemVersion > 3.2 || systemVersion == 3.2 ) { //Stuff } 

I know that floating point can lead to some odd comparison of behavior due to accuracy, but will the behavior be higher than a piece of code below?

 float systemVersion = [[[UIDevice currentDevice] systemVersion] floatValue]; if (systemVersion >= 3.2) { //Stuff } 
+4
source share
2 answers

It is the same. In many compilers, the resulting machine instructions are exactly the same (although I cannot say for sure that this is true for clang).

+2
source

No, it will not. I think this code, which turned out to be this way by chance (maybe after a few minor adjustments).

+1
source

Source: https://habr.com/ru/post/1432341/


All Articles