42. My C # learning Note 8

Source: Internet
Author: User

Bitwise operators other than bitwise AND, bitwise, OR operator, can only be used to manipulate integers. Bit operations are purely bit-oriented.

1. Bitwise -and Operation

The operator of the bitwise-and operation is&, and the bitwise-to operation is: If two integer data aandb correspond to all 1 , the result bit is 1, otherwise 0. If the accuracy of the two operands is different, the result is the same precision as the operand with high precision.

2. Bitwise OR Operation

The operator for the bitwise OR operation is| ", the" bitwise OR "operation is: if the two operands correspond to 0 The result is 0 , otherwise the 1 . If the accuracy of the two operands is different, the result is the same precision as the operand with high precision.

3. Bitwise Inverse Operation

The bitwise negation operation is also called a bitwise NOT operation, and the operator is "~", which is a monocular operator. The bitwise negation operation is to modify 1 in the operand binary to 0and0 to 1.

4. Bitwise XOR Operator

^ 0 1 0 Span style= "font-family: ' Times New Roman ';" >1

5. the data can be shifted by bits. C # the following two types of shift operators are available. <<: Move left. >> move right.

ForX<<norX>>nthe operation of the form, meaning that thexmove left or rightNbit, the resulting type ofxsame. In this place,xcan only be of typeint,UINT,LongorULONG,Ncan only be of typeint, or the display is converted to one of these types, otherwise, a syntax error occurs when the program is compiled. When specifically executed, the left shift is the number of bits specified by the left-hand operand in-memory binary data to the right of the operand, and the empty portion of the right is 0. Moving right is a bit more complicated when using the ">>"symbol, if high0, left-shifted bits are entered0; If the highest bit is1, left-shifted bits are entered1.

The shift can achieve an integer divided by or multiplied by 2 of the n -th side effect.



This article is from the "Smile" blog, please be sure to keep this source http://yiyiweixiao.blog.51cto.com/2476874/1977466

42. My C # learning Note 8

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.