Binary code Types and length of binary code. Reverse binary code

Binary code is a form of recording information in the form of ones and zeros. Such a calculus system is positional with a base of 2. Today, the binary code (the table presented below contains some examples of writing numbers) is used in all digital devices without exception. Its popularity is due to the high reliability and simplicity of this form of recording. Binary arithmetic is very simple, respectively, it is easy to implement it at the hardware level. Digital electronic components (or, as they are also called, logical) are very reliable, since they operate in only two states: a logical unit (there is a current) and a logical zero (there is no current). Thus, they compare favorably with analog components, whose operation is based on transients.

binary code

How is binary notation compiled?

Let's see how such a key is formed. One bit of binary code can contain only two states: zero and one (0 and 1). When using two digits, it becomes possible to write four values: 00, 01, 10, 11. Three-digit recording contains eight states: 000, 001 ... 110, 111. As a result, we find that the length of the binary code depends on the number of digits. This expression can be written using the following formula: N = 2m, where: m is the number of digits, and N is the number of combinations.

Types of Binary Codes

In microprocessors, such keys are used to record a variety of processed information. The capacity of the binary code can significantly exceed the capacity of the processor and its internal memory. In such cases, long numbers occupy several cells of the storage device and are processed using several commands. Moreover, all sectors of memory that are allocated for multibyte binary code are considered as a single number.

kinds of binary codes
Depending on the need to provide this or that information, the following types of keys are distinguished:

  • unsigned;
  • direct integer character codes;
  • significant inverse;
  • significant additional;
  • Gray code
  • Gray Express code .;
  • fractional codes.

Let us consider in more detail each of them.

Unsigned binary code

Let's see what constitutes this type of recording. In integer unsigned codes, each digit (binary) represents the power of two. Moreover, the smallest number that can be written in this form is zero, and the maximum can be represented by the following formula: M = 2 p -1. These two numbers fully determine the range of the key with which such a binary code can be expressed. Let's look at the possibilities of the mentioned form of recording. When using this type of unsigned key, consisting of eight digits, the range of possible numbers will be from 0 to 255. The sixteen-bit code will have a range from 0 to 65535. In eight-bit processors, two sectors of memory are used to store and write such numbers, which are located in neighboring addresses . Work with such keys is provided by special teams.

Direct integer signed codes

In this form of binary keys, the most significant digit is used to record the sign of a number. Zero corresponds to plus, and one to minus. As a result of the introduction of this category, the range of encoded numbers is shifted in the negative direction. It turns out that an eight-digit signed integer binary key can record numbers in the range from -127 to +127. Sixteen-bit - in the range from -32767 to +32767. In eight-bit microprocessors, two neighboring sectors are used to store such codes.

The disadvantage of this form of recording is that the sign and digital digits of the key must be processed separately. Algorithms for programs working with these codes are very complex. To change and highlight significant digits, it is necessary to apply the masking mechanisms of this symbol, which contributes to a sharp increase in the size of the software and a decrease in its speed. In order to eliminate this drawback, a new type of key was introduced - reverse binary code.

reverse binary

Signed Return Key

This form of writing differs from direct codes only in that a negative number in it is obtained by inverting all digits of the key. In this case, the digital and sign digits are identical. Due to this, the algorithms for working with this type of code are greatly simplified. However, the reverse key requires a special algorithm for recognizing the symbol of the first digit, calculating the absolute value of the number. As well as restoring the sign of the resulting value. Moreover, in the reverse and forward codes of a number, two keys are used to write zero. Despite the fact that this value does not have a positive or negative sign.

binary optional code

Signed optional binary number code

This type of record does not have the listed disadvantages of the previous keys. Such codes allow direct summation of both positive and negative numbers. In this case, the analysis of the sign discharge is not carried out. All this has been made possible thanks to the fact that the extra numbers are a natural ring of characters, and not artificial formations such as direct and reverse keys. Moreover, an important factor is that it is extremely simple to compute additions in binary codes. To do this, it is enough to add one to the reverse key. When using this type of sign code, consisting of eight digits, the range of possible numbers will be from -128 to +127. A sixteen-digit key will have a range from -32768 to +32767. Eight-bit processors also use two neighboring sectors to store such numbers.

The binary additional code is interesting for the observed effect, which is called the sign propagation phenomenon. Let's see what that means. This effect consists in the fact that in the process of converting a single byte value to a double byte, it is sufficient for each bit of the high byte to assign the values ​​of the sign bits of the low byte. It turns out that you can use the most significant bits to store the signed character of a number . In this case, the key value does not change at all.

Gray Code

This form of recording, in fact, is a one-step key. That is, in the process of transition from one value to another, only one bit of information changes. Moreover, the error in reading data leads to a transition from one position to another with a slight time offset. However, obtaining a completely incorrect result of the angular position during such a process is completely excluded. The advantage of such a code is its ability to mirror information. For example, by inverting the most significant bits, you can simply change the reference direction. This is due to the Complement control input. In this case, the output value can be either increasing or decreasing with one physical direction of rotation of the axis. Since the information recorded in the Gray key is exclusively encoded in nature, which does not carry real numerical data, before further work it is required to first convert it to the usual binary form of writing. This is done using a special converter - the Gray-Binar decoder. This device is easily implemented on elementary logic elements both hardware and software.

Gray Express Code

The standard one-step key Gray is suitable for solutions that are presented in the form of numbers raised to the power of two. In cases where it is necessary to implement other solutions, only the middle section is cut out and used from this form of recording. As a result, a one-step key is saved. However, in such a code, the beginning of the number range is not zero. It is shifted by the set value. During data processing, half the difference between the initial and reduced resolution is subtracted from the generated pulses.

binary code length

Fractional Representation in Fixed-Point Binary Key

In the process, you have to operate not only with whole numbers, but also fractional ones. Such numbers can be written using direct, inverse, and additional codes. The principle of construction of the mentioned keys is the same as that of integers. Until now, we believed that the binary comma should be to the right of the least significant bit. But this is not so. It can be located to the left of the high order (in this case, only fractional numbers can be written as a variable), and in the middle of the variable (mixed values ​​can be written).

binary code table

Floating point binary representation

This form is used to write large numbers, or vice versa - very small. Interstellar distances or the sizes of atoms and electrons can be given as an example. When calculating such values, one would have to use binary code with a very large bit depth. However, we do not need to take into account the space distance to the nearest millimeter. Therefore, the fixed-point recording form is ineffective in this case. To display such codes, an algebraic form is used. That is, the number is written as a mantissa, multiplied by ten in a degree that displays the desired order of the number. You should know that the mantissa should not be more than one, and zero should not be written after the decimal point.

binary coding

It is interesting

It is believed that binary calculus was invented at the beginning of the 18th century by German mathematician Gottfried Leibniz. However, as scientists recently discovered, long before that, the aborigines of the Polynesian island Mangareva used this type of arithmetic. Despite the fact that colonization almost completely destroyed the original calculus, scientists have restored complex binary and decimal types of accounts. In addition, the Cognitive scientist Nunez claims that binary coding was used in ancient China as early as the 9th century BC. e. Other ancient civilizations, such as the Maya Indians, also used complex combinations of decimal and binary systems to track time intervals and astronomical phenomena.


All Articles