In VC2008, I typed this code:
int a = 2 + 1 & 0;
and this expression is obtained a = 0
Why is the result equal to 0 but not 2?
Since the operator & is evaluated after the operator + and 3 & 0 is 0 .
&
+
3 & 0
0
Of course, you can put braces around expressions to change the order of evaluation. For instance:
int a = 2 + (1 & 0); /* a == 2 */
+ has a higher priority than & . Here is a complete table of operator priorities.
Source: https://habr.com/ru/post/904679/More articles:Does Resharper 6.1 support working with MBUnit? - resharperJava proxy authentication - javaIs there a connection between object size and performance locking in Java? - javaClosing an HttpClient connection before logging out - javaLinq Where Contains ... Keep the default order - c #HTML towards the tag: can I use forms to report errors? - cssConfiguring an MVC3 application using jquery? - performanceis there a built-in javascript hash function in newer browsers? - javascriptIE9 JSON Data To Iframe: "Do you want to open or save this file?" - jsonvim syntax syntax for scss - syntaxAll Articles