Bit operators and Computer Data Storage

Source: Internet
Author: User

Bitwise operators can only process (Signed/unsigned) random, short integer, and integer variable constant literal values, but cannot perform decimal operations. You can also perform Operator Overloading in the class.

When there are too many threads, there are too many threads, too many threads.
Operator Function
── ─
& Bit logic and
| Bit logic or
^ Bit logic exclusive or
-Bit logic inversion
> Right shift
<Move left
When there are too many threads, there are too many threads, too many threads.

 

& Bit logic and

PhaseTrue and false. Others are false.

 

| Bit logic or

By phase or, same as falseIs false, and others are true.

 

^ Bit logic exclusive or

Bitwise difference or, the difference is true, the same is false.

 

-Bit logic inversion

Returns the inverse of each digit.

 

> Right shift

Remove the symbol bit of the data to add an original symbol (it can also be understood as adding a symbol to the highest data bit without changing the symbol bit)

Example: positive number 0010 0000 0000> 1 1011 0001 0000 0000

Negative 1000 0000 0000 0000> 1 1100 0000 0000 0000
<Move left

The highest bit of data is removed. The lowest Bit is 0.

Example:Positive number 0010 0000 0000 1011 <1 0100 0000 0001 0110

Negative1000 0000 0000 0000<1 0000 0000 0000 0000

 

Note that data is stored in the computer in the form of a complement.

For signed data, the highest bit indicates that the sign bit 0 represents a positive number 1 represents a negative number.

The positive and reverse completion codes of positive numbers are consistent.

The negative number is the inverse of each digit of the positive code (except the symbol bit), and the complement is the last digit + 1 of the reverse code.

 

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.