Home > Common Problem > body text

The relationship between the complement of negative numbers and the original code

小老鼠
Release: 2023-12-22 10:46:25
Original
1840 people have browsed it

Existing relationship: 1. The complement of a negative number is the inversion of all bits of the original code except the sign bit, and then the lowest bit is added by 1; 2. The complement of a positive number is the same as its original code; 3. Negative numbers The complement of can be obtained by using the positive original code 1.

The relationship between the complement of negative numbers and the original code

There is the following relationship between the complement of a negative number and the original code:

  1. The complement of a negative number is the division sign of its original code Invert all other bits, then add 1 to the lowest bit.
  2. The complement of a positive number is the same as its original code.
  3. The complement of a negative number can be obtained by using the original code of a positive number 1.

For example, find the complement of -5: The positive number corresponding to

  1. -5 is 5.
  2. Invert 5 bitwise to get 0101.
  3. Add 1 to the end of 0101 to get 01011, which is the complement of -5.

Therefore, the relationship between the complement of a negative number and the original code is: the complement of a negative number is the inversion of all bits of the original code except the sign bit, and then adding 1 to the lowest bit.

The above is the detailed content of The relationship between the complement of negative numbers and the original code. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!