Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the bit operators supported by C #

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "what bit operators C#supports", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "what bit operators C#supports"!

bitwise operators

Bitwise operators act on bits and perform operations bitwise.&, | The truth table for and ^is as follows:

pqp & qp | qp ^ q00000010111111010011

Suppose if A = 60 and B = 13, now expressed in binary format, they are as follows:

A = 0011 1100

B = 0000 1101

-----------------

A&B = 0000 1100

A|B = 0011 1101

A^B = 0011 0001

~A = 1100 0011

The following table lists the bit operators supported by C#. Assuming variable A has a value of 60 and variable B has a value of 13, then:

Operator Description Instance & Binary AND operator copies one bit into the result if present in both operands. (A & B) will get 12, which is 0000 1100| The binary OR operator copies one bit into the result if present in either operand. (A |B) will result in 61, which is 0011 1101^If present in one of the operands but not both, the binary XOR operator copies one bit into the result. (A ^ B) will result in 49, which is 0011 0001~ The bitwise negation operator is a unary operator with a "flip" bit effect, i.e. 0 becomes 1 and 1 becomes 0, including the sign bit. (~A ) will result in-61, which is 1100 0011, a signed binary complement.> 2 will get 15, that is, 0000 1111 to this, I believe everyone has a deeper understanding of "what bit operators C#supports", may wish to actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report