On the complement and inverse code of non-binary system

Source: Internet
Author: User

About Name

The complement should be called diminished Radix complement, and the anti-code is Radix complement. The most common so-called 1 ' s complement with 2 ' s complement are actually relative to the 2 binary.

That is, for 2 binary , diminished Radix complement can be called 1' s Complement,radix complement can be called 2' s complement. Then for the 8 binary , the diminished Radix complement should be called 7' s complement and Radix complement 8' s complement.

Note that the 2 ' s complement name is the complement to the 2 binary, and for the 3 binary is the inverse code, and so on.

Calculation method

Algorithm of diminished Radix complement

The number of BITS is n, the numbers that need to be computed are N, and the R-binary, then its inverse code ((r-1) ' s complement) is
(rn–1) –n
Calculation, rn-1 with the same binary representation is more convenient, such as three-bit 10 binary 105-1 is the 99999,8 85-1 is (77777) 8

Like what
(AA) 16 of the inverse Code(complement) is (FF)-(aa) 16 = (55) 16
(546700) 10 of the Anti-code (9' s complement) is (999999) 10– (546700) 10 = (453299) 10
(017) 8 of the Anti-code (7' s complement) is (777) 8-(017) 8 = (760) 8
(1011000) 2 of the Anti-code (1' s complement) is (1111111) 2-(1011000) 2 = (0100111) 2

This means that a number plus their own anti-code gets the rn-1, which is 10 binary 99999,8 (77777) 8 so

The algorithm of Radix complement

Are the same as the 2 binary 2 ' s complement, Radix complement=diminished Radix complement + 1
or (rn–1) –n + 1, simplified is rn–n, but the former borrow generally less than (imagine 999-621 and 1000-621, which is good?) ), more convenient.

(AA) 16 of the complement(s complement) is (FF)-(AA) 16 + 1 = (56) 16
(546700) 10 of the complement (ten' s complement) is (999999) 10– (546700) 10 + 1 = (453300) 10
(017) 8 of the complement (8' s complement) is (777) 8-(017) 8 + 1 = (761) 8
(1011000) 2 of the complement (2' s complement) is (1111111) 2-(1011000) 2 + 1 = (0101000) 2

This means that a number plus your own complement gets the RN, which is a 1 followed by a heap of 0, such as the 10 binary 100000,8 (10000) 8.

Reference: Http://www2.southeastern.edu/Academics/Faculty/galkadi/297/notes/chapter1.doc (a book that should come from M.morris.mano)

On the complement and inverse code of non-binary system

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.