Java binary, original code, inverse code, complement, bit operation

Source: Internet
Author: User
Tags bitwise
1. The concept of binary counting method in daily life and production practice, we are exposed to more and more numbers, creating a system of grouping counts. And in our lives, we generally adopt the decimal notation of "full 10 in one", We are now familiar with and often use this method of counting. But there are other counting methods. such as binary, six-binary, 16-binary counting. Now it's about the "binary" and "decimal" Relationships 2. Decimal and binary number Interoperability (1) Decimal number binary number <1> A smaller decimal number is a binary number that can be used for observation. Example: 45 is a binary number because 2 of the 0-square, 1-square, 2-square-~~~10-square respectively equals 1,2,4,8,16,32,64,128,256,512,1024. So 45=32+8+4+1=2⑤+2③+ 2②+1=1*2⑤+0*2④+1*2②+0*2①+1*1=101101 (binary) <2> generalized method using short division (commonly called "two-in-one") (2) binary number is a decimal number this is more convenient, just the binary is written in the expansion; 3 for the highest bit of a signed binary number, the symbol bit: 0 for positive numbers, 1 for negative numbers of the original code, anti-code, complement are the same negative number of anti-code = its original code symbol bit unchanged, the other bit to reverse the complement of negative numbers = Its anti-code +10 of the anti-code, the complement is 0java in the numbers are signed in the computer operation of the time , they are all in the form of a complement. There are 4 median operations in Java, respectively, bitwise and &, bitwise OR |, bitwise XOR, bitwise negation. &: The two-bit is all 1, the result is 1|: two bits have a 1, the result is 1^: two bits have one 1, one is 0, the result is 1 inversion: 0 Take the inverse of the reverse bit 0 in Java there are 3 shift operators >> arithmetic right shift: low overflow, sign bit unchanged, High << arithmetic left shift with symbol bit fill overflow: sign bit invariant, low 0>>> logic right Shift: low overflow, high 0

Java binary, original code, inverse code, complement, bit operation

Related Article

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.