self completing code

怎甘沉沦 提交于 2020-01-24 00:38:06

问题


https://electronics.stackexchange.com/questions/20537/how-to-identify-self-complementing-code

I have read that properly ,

but is it necessary that , the number need to be subtracted from 9 ?

because in the 8421 system 12= 1100

and if we subtract 15-12 , then the answer is 3 , which is 0011 .

so it is also self complementing...

I don't understand that , the given number need to be subtracted from which number , is that number neccessary to be 9 ???


回答1:


If the sum of the weights is 9 then it is self complementing e.g 5211=(5+2+1+1)=9 or 2421=(2+4+2+1)=9 8421 is not self complementing so ,8421!=9.




回答2:


A self complementing code for Base-10 is a code for which the complement of a given encoded digit d [0-9] will result in 9-d, the 9's complement.

To encode Base-10 numbers in binary, we need to be able to represent 10 values [0-9] which means we require 4 bits because 3 bits can represent 8 values which is not enough; 4 bits can represent 16 values, which is more than we need, but we don't have (or want) fractional bits.

There are numerous encoding schemes possible within these 4 bits, the most intuitive of which is the 8-4-2-1 scheme, or straight binary encoding of the decimal value. To encode 12 using 8-4-2-1, you would separately encode [1] and [2] as their respective binary representations [0001] and [0010].

The 9's complement is relevant in the context of binary encoding decimal/Base-10 numbers because 9 is the largest value required when encoding Base-10 numbers.

Your example implies Base-16, displayed as decimal, for which you are correctly generating the 15's complement rather than the 9's complement. 8-4-2-1 is intuitively a self complementing code for Base-16, because taking the complement of a 4 digit binary number is the same as subtracting it from 15.

The same cannot be said for a Base-10 number represented the same way, because we are representing only 10 values in 16 member code space, which is why a number of more intricate systems have been devised to generate self-complementing codes for representation of decimal numbers in 4 digit binary numbers.

Table 13.1 here: [ http://www.inf.fu-berlin.de/lehre/WS00/19504-V/Chapter1.pdf ] shows two self-complementing codes for decimal encoding, namely the 8,4,-2,-1 and excess-3 encoding schemes, and the subsequent section describes the purpose and theory behind self-complementing codes.




回答3:


Some rephrasing for clarification: IIRC it means when visible number is subtracted from 9, "number" of coding is bit-inverted, i.e. subtracted from 15.

One can code e.g. 0 = 0011, 1 = 0100, 2 = 0101, ..., 9 = 1100 (so-called excess-3, see modi's reply for details.



来源:https://stackoverflow.com/questions/9850097/self-completing-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!