Does objective-c follow the order of operations (Bedmas)?

自作多情 提交于 2019-12-01 21:10:49

Yes. Objective-C is a superset of C.

So all the features that C has, Objective-C has as well.

 360 * num1 * num3 * (1 - powf(14.9 / num1, 0.286)) (num1 and num3 are the input numbers)
          A * num3 * (1 - powf(14.9 / num1, 0.286)) 
                 B * (1 - powf(14.9 / num1, 0.286)) 
                 B * (1 - powf(C, 0.286)) 
                 B * (1 - D) 
                 B * (E) 
                      F 

And just for information, BEDMAS is not fully followed. If D & M are there at same level, the left most will be evaluated first, and so is the rule for A & S. However this does not look big deal, but when it comes to truncation and rounding with decimal numbers it creates a big problem.

a * b / c is calculated  as "(a*b) / c" 

whereas

a / b * c is calculated as "(a/b) * c" 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!