Working Through DIGITAL ELECTRONICS NOTES (2. Quiz on Codes)

I'm working through the following digital circuit problems. Continued.

lancamentomerlo.my.canva.site

    1. What is a parity bit, and how is it calculated?

A parity bit is a bit appended to the end of a string of binary code that indicates whether the number of bits with the value "1" in the string is even or odd. Accordingly, there are two kinds of parity: even parity and odd parity.

To calculate the parity bit, count the total number of bits with the value "1" in the binary code. If the number of "1"s is odd and even parity is used, the parity bit is set to 1 so that the total number of "1"s including the parity bit is even. If the number of "1"s is odd and odd parity is used, the parity bit is set to 0 so that the total number of 1s including the parity bit is odd.

The parity bit is calculated by taking the XOR of all the bits in the binary string. The parity bit is used as the simplest error-detecting code.

    1. For the given binary string 111001, calculate the appropriate odd parity bit.

The given binary string 111001 has four "1"s. When using odd parity, the total number of "1"s in the binary string including the parity bit must be odd. Therefore, the odd parity bit for this string is 1.

    1. What are one's complement and two's complement? Where are they used?

Inverting every bit of a binary number, turning 1s into 0s and 0s into 1s, gives the one's complement. For example, the one's complement of the binary number 110010 is 001101.

The two's complement of a binary number is obtained by adding 1 to its one's complement. For example, the two's complement of the binary number 110010 is 001101+1 = 001110.

Two's complement is used to represent signed binary numbers. It is also used for binary subtraction. One's complement is an intermediate step toward obtaining the two's complement.

    1. What is BCD code, and how does it differ from binary code? What are the BCD code and the binary code for the decimal number 27?

BCD stands for Binary Coded Decimal, a 4-bit binary code that can represent any single decimal digit (0 to 9). Binary code represents a decimal number as a binary number, so the number of bits required for binary code depends on the decimal number. For decimal numbers from 0 to 9, BCD and binary code are the same.

The number 27 can be represented in BCD by representing 2 and 7 with 4 bits each. Therefore, the BCD for 27 is 0010 0111.

    1. What is a weighted code? Give an example.

A weighted code has a fixed weight assigned to each position. For example, in ordinary binary, you can obtain the equivalent decimal value by multiplying the value at each position by the weight of that position and adding them up.

    1. What are the features of the Excess-3 code?

It is self-complementing. The 9's complement of an Excess-3 value is obtained simply by inverting the bits.

    1. Give an example of a non-weighted code.

Unlike weighted codes, it is a code that has no weights. Examples include the Excess-3 code and the Gray code. Therefore, a number represented in a non-weighted code cannot be converted directly to decimal.


This is an English translation of the original Japanese post: DIGITAL ELECTRONICS NOTESをやってみる (2. 符号に関するクイズ)