The complement of the opposite number of a number

Source: Internet
Author: User

1. Known as the 8-bit binary representation of the integer x's complement of 10011011, then-X's complement of the two-step

Encoded as ( 01100101 ).

Parsing: X and-X are known to be opposite to each other, so the complement of X is known, [x] counter = [x] complement-1,

(x is negative)

Then-X (-X is positive) the complement of [-X] complement = [x] anti =-([x] complement-1) =-[x] Complement + 1

First you take the counter, 0 becomes 1, 1 becomes 0. Then the lowest bit plus one.

If you think so:

Given a positive complement, how do you ask for the complement of the opposite number?

Parse: The original, inverse, and complement of positive numbers are the same.

The original code of his inverse number is the modifier sign bit (highest bit),

Anti-code is in addition to the symbol bit, the rest of you bitwise reverse,

Complement is anti-code +1

So, this process is reversed for each bitwise and then added 1

Q: Given the complement of a negative number, how can I ask for the complement of his opposite?

Parsing: That nature is on the process inverse process:

First minus one, in the bitwise reverse

See the process, that is, the bitwise reverse, plus a

x=10011011-x=01100101-2x= (-X left one fill 0, more that bit ignored) 11001010;

x=11001101 (look at X, move right one of the original first is what is now or what); -1/2x=00110010 (by the same token, see-X)


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Complement the opposite number of a number

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.