Home > Backend Development > C#.Net Tutorial > You must understand the difference between & and && in C language

You must understand the difference between & and && in C language

烟雨青岚
Release: 2020-06-17 13:15:00
forward
5685 people have browsed it

You must understand the difference between & and && in C language

##You must understand the difference between & and && in C language

## The difference between & and && in #c language is as follows:

&: According to bitwise AND operation,

For example: 0010&1101, the result is 0000 & is in java The bit logic operation:

eg: 2&3=2;


The analysis is as follows: The binary system of 2 is 10; the binary system of 3 is 11; after the logical &, it is 10

&& : Short-circuit AND, indicating that if both conditions are true, the subsequent logic will be executed;

For example: if(a==0&&b==0), which means if a is 0 and b is 0 time, proceed to the next step.

|| 短路或。 A||B,只有当A为假的时候才会对B进行判断。若A为真,则不继续对B进行判断。
| 逻辑或。 A|B,会对A, B都进行判断
! 逻辑非,当操作数为true时,返回false,否则返回true。
Copy after login

Thank you everyone for reading, I hope you will benefit a lot.

This article is reproduced from: https://blog.csdn.net/xiachong27/article/details/82119394

Recommended tutorial: "

C Language

"

The above is the detailed content of You must understand the difference between & and && in C language. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template