比较类似术语之间的差异

Difference Between

家 / 技术 / IT / Programming /Difference Between Bitwise and Logical Operators

Difference Between Bitwise and Logical Operators

2018年2月6日发表Lithmee

Key Difference – Bitwisevs Logical Operators

In programming, there are situations to perform mathematical computations. An operator is a symbol of programming languages to perform specific logical or mathematical functions on a value or a variable. There are various operators in programming languages. Some of them are arithmetic operators, relational operators, logical operators, bitwise operators and assignment operators. Arithmetic operators support mathematical operations such as addition (+), subtraction (-), division (/), multiplication (*), modulus (%), incrementing (++) and decrement (–). Relation operators are >, > =, <, <=, == or !=. These operators help to find the relationship of operands. Assignment operators assign values from right side operand to left side operand. Bitwise operators are &, |, ^. Logical operators are &&, ||,!. This article discusses the difference between bitwise and logical operators. Thekey differencebetween Bitwise and Logical operators is thatBitwise operators work on bits and perform bit by bit operations while logical operators are used to make a decision based on multiple conditions.

内容

1.Overview and Key Difference
2.什么是位运算符
3.What are Logical Operators
4.Similarities Between Bitwise and Logical Operators
5。Side by Side Comparison – Bitwise vs Logical Operators in Tabular Form
6。概括

什么是位运算符?

钻头操作员处理位,并通过位操作执行。在诸如加法,减法,乘法,除法等计算中。值将其转换为二进制. Those operations are performed on bit level. Bit-level processing is used to increase speed and to save power. Some examples of Bitwise operators are as follows. The & represents bitwise AND. The | represents bitwise OR. The ^ represents bitwise exclusive OR. The ~ is the complement. The << symbol is to represent the left shift while >> symbol represents the right shift.

钻头和操作如下。当x和y是操作数时,x具有值0,y具有值0,然后是0。然后位于0,为0。当x和y都有1个,位和1。仅当两个操作数包含值1时,输出才是1。假设20和25为两个值。20的二进制为10100。25的二进制为11001。11001。这两个数字为10000。当逐个点和操作执行时,仅在两个操作数包含一个时,一个值才能。

钻头或操作如下。当x和y是操作数时,x具有值0,y具有值0,然后是0。当x为0且y为1时,输出为1时。IS 1.当x和y都具有值1时,输出为1。从两个操作数中,如果一个操作数为1,则是1个操作数,则为1。假设20和25为两个值。20的二进制为10100。25的二进制为11001。比特或20和25的二进制为11101。

如果两个值都不同,钻头XOR操作员将获得1个。当x和y操作数为零时,xor xor为0。当x为0和y时,输出为1时。1,然后输出为0。20和25的位XOR为01101。〜符号是取值。二进制值为20为10100。补体为〜20 =01011。将其转换为零并将零转换为零。

The << is the binary left shift operator. The left operands value is moved left by the number of bits specified by the right operand. In example 5 << 1, the binary value of 5 is 0101. 0101<<1 is 1010. The >> is the binary right shift operator. The left operands value is moved right by the number of bits specified by the right operand. As an example, 5 >>1, 0101 >> 1 is 0010.

What are Logical Operators?

The logical operators are used to make a decision based on multiple conditions. The && symbol represents the logical AND. The || symbol represents the logical OR. The ! symbol represents the logical NOT. In logical AND, if both operands are non zero, then the condition becomes true. In logical OR, if both operands are non zero, then the condition becomes true. The ! operator can reverse the logical status of the operand. If a condition is true, then Logical NOT operator will make it false. The true represents value 1, and falsely represents value 0.

Difference Between Bitwise and Logical Operators

Figure 01: Bitwise and Logical Operators

When variable x is holding the value 1 and variable y is holding the value 0, the logical AND that is (x && y) is false or 0. The logical OR that is (x || y) will give true or 1. The NOT operator reverses the logical status. When x is having value 1, then ! x is 0. When y is having value 0, then !y is 1.

What is the Similarity Between Bitwise and Logical Operators?

  • 两者都是编程中的运算符,以在值或变量上执行特定的逻辑或数学函数。

位和逻辑运算符有什么区别?

比特与逻辑运算符

Bitwise Operator是编程语言提供的运算符类型来执行计算。 逻辑操作员是编程语言提供的一种运算符,用于执行基于逻辑的操作。
功能
Bitwise operators work on bits and perform bit by bit operations. 逻辑运营商用于根据多种条件做出决定。
主题
Bitwise operators are &, |, ^, ~, <<, >>. 逻辑运算符是&&,||,!

概括– Bitwisevs Logical Operators

在程序设计中,有必要做这个tical and logical operations. They can be achieved using operators. There are various types of operators. This article discussed the difference between two operators such as bitwise operators and logical operators. The difference between Bitwise and Logical operators is that Bitwise operators work on bits and perform bit by bit operations while logical operators are used to make a decision based on multiple conditions.

下载位于位的PDF与逻辑运算符

You can download the PDF version of this article and use it for offline purposes as per citation note. Please download the PDF version here:Difference Between Bitwise and Logical Operators

Reference:

1. tutorialspoint.com。“ C运营商。”The Point.Available here

相关文章:

Difference Between Dictionary and Hashtable 第四代和第五代编程语言(4GL和5GL)之间的差异 Difference Between API and SDK C和嵌入式C之间的差异 机器依赖和机器独立代码优化之间的差异机器依赖和机器独立代码优化之间的差异

Filed Under:Programming标记为:比特和逻辑运营商的差异,比特和逻辑运营商的相似性,Bitwise Operators,Bitwise Operators Definition,位运算符功能,Bitwise Operators Theme,比特与逻辑运算符,比较位和逻辑操作员,逻辑操作员,逻辑运算符定义,逻辑操作员Function,逻辑运营商主题

关于the Author:Lithmee

Lithmee Mandula是计算机系统工程的孟加(荣誉)。她目前正在攻读计算机科学硕士学位。她在写作和研究方面的兴趣领域包括编程,数据科学和计算机系统。

发表评论取消回复

Your email address will not be published.Required fields are marked*

请求文章

Featured Posts

Difference Between Coronavirus and Cold Symptoms

Difference Between Coronavirus and Cold Symptoms

冠状病毒和SARS之间的差异

冠状病毒和SARS之间的差异

Difference Between Coronavirus and Influenza

Difference Between Coronavirus and Influenza

冠状病毒和covid 19之间的差异

冠状病毒和covid 19之间的差异

你可能喜欢

Difference Between Mermaid and Trumpet

参考书目和注释参考书目之间的差异

参考书目和注释参考书目之间的差异

Difference Between Electric Fireplace and Gas Fireplace

黄金猎犬和黄色实验室之间的差异

What is the Difference Between Classroom Management and Discipline

What is the Difference Between Classroom Management and Discipline

最新的帖子

  • What is the Difference Between Vitamins and Amino Acids
  • What is the Difference Between Induction Cooker and Normal Cooker
  • 白癜风和牛皮癣有什么区别
  • 取消和皮质骨有什么区别
  • 电力和感应灶具有什么区别
  • What is the Difference Between Prevention and Cure
  • 家
  • Vacancies
  • 关于
  • 请求文章
  • 联系我们

Copyright © 2010-2018Difference Between. All rights reserved.Terms of Use和隐私政策:合法的.