Bitwise operator Summary

Source: Internet
Author: User
Tags bitwise operators
Six bitwise operators & | ^ ~ <> & Bitwise AND operator: Calculate the location and binary length of a binary short value, that is, 1 & 1 = 1 & 0 = 0 0 & 0 = 0 | Press bitwise parallel operators perform parallel operations based on the position and length of the binary, that is, 1 | 1 = 1 1 | 0 = 1 0 | 0 = 0 ^ XOR operations are the same as 0, the difference is 1 1 ^ 1 = 0 0 ^ 0 = 0 1 ^ 0 = 1 ~ The inverse operation swaps 0 and 1 by 1110 ~ 0001 <left shift operation shifts the binary value to the left 110 <1 = 1100> right shift operation shifts the binary value to the right 110> 1 = 11 test code
# Include <bits/stdc ++. h> using namespace STD; int main () {int A, B; while (CIN> A> B) {cout <(A & B) <"\ n"; cout <(A | B) <"\ n"; cout <(a ^ B) <"\ n "; cout <(~ A) <"<(~ B) <"\ n"; cout <(A <2) <"\ n"; cout <(B> 2) <"\ n ";}}
Test Results

Bitwise operator Summary

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.