Computer lessons

Solve binary codes. Russian alphabet in binary code

Binary code represents text, computer processor instructions, or other data using any two-character system. Most commonly, it is a system of 0s and 1s that assigns a pattern of binary digits (bits) to each symbol and instruction. For example, a binary string of eight bits can represent any of 256 possible values ​​and can therefore generate many different elements. Reviews of binary code from the global professional community of programmers indicate that this is the basis of the profession and the main law of the functioning of computer systems and electronic devices.

Deciphering the binary code

In computing and telecommunications, binary codes are used for various methods of encoding data characters into bit strings. These methods can use fixed-width or variable-width strings. There are many character sets and encodings for converting to binary code. In fixed-width code, each letter, number, or other character is represented by a bit string of the same length. This bit string, interpreted as a binary number, is usually displayed in code tables in octal, decimal, or hexadecimal notation.

Binary Decoding: A bit string interpreted as a binary number can be converted to a decimal number. For example, the lowercase letter a, if represented by the bit string 01100001 (as in standard ASCII code), can also be represented as the decimal number 97. Converting binary code to text is the same procedure, just in reverse.

How it works

What does binary code consist of? The code used in digital computers is based on which there are only two possible states: on. and off, usually denoted by zero and one. While in the decimal system, which uses 10 digits, each position is a multiple of 10 (100, 1000, etc.), in the binary system, each digit position is a multiple of 2 (4, 8, 16, etc.). A binary code signal is a series of electrical pulses that represent numbers, symbols, and operations to be performed.

A device called a clock sends out regular pulses, and components such as transistors are turned on (1) or off (0) to transmit or block the pulses. In binary code, each decimal number (0-9) is represented by a set of four binary digits or bits. The four basic operations of arithmetic (addition, subtraction, multiplication, and division) can be reduced to combinations of fundamental Boolean algebraic operations on binary numbers.

A bit in communication and information theory is a unit of data equivalent to the result of a choice between two possible alternatives in the binary number system commonly used in digital computers.

Binary code reviews

The nature of code and data is a basic part of the fundamental world of IT. This tool is used by specialists from the global IT “behind the scenes” - programmers whose specialization is hidden from the attention of the average user. Reviews of binary code from developers indicate that this area requires a deep study of mathematical fundamentals and extensive practice in the field of mathematical analysis and programming.

Binary code is the simplest form of computer code or programming data. It is entirely represented by a binary digit system. According to reviews of binary code, it is often associated with machine code because binary sets can be combined to form source code that is interpreted by a computer or other hardware. This is partly true. uses sets of binary digits to form instructions.

Along with the most basic form of code, a binary file also represents the smallest amount of data that flows through all the complex, end-to-end hardware and software systems that process today's resources and data assets. The smallest amount of data is called a bit. The current strings of bits become code or data that is interpreted by the computer.

Binary number

In mathematics and digital electronics, a binary number is a number expressed in the base-2 number system, or binary numeric system, which uses only two characters: 0 (zero) and 1 (one).

The base-2 number system is a positional notation with a radius of 2. Each digit is referred to as a bit. Due to its simple implementation in digital electronic circuits using logical rules, the binary system is used by almost all modern computers and electronic devices.

Story

The modern binary number system as the basis for binary code was invented by Gottfried Leibniz in 1679 and presented in his article "Binary Arithmetic Explained". Binary numbers were central to Leibniz's theology. He believed that binary numbers symbolized the Christian idea of ​​creativity ex nihilo, or creation out of nothing. Leibniz tried to find a system that would transform verbal statements of logic into purely mathematical data.

Binary systems that predate Leibniz also existed in the ancient world. An example is the Chinese binary system I Ching, where the divination text is based on the duality of yin and yang. In Asia and Africa, slotted drums with binary tones were used to encode messages. The Indian scholar Pingala (circa 5th century BC) developed a binary system to describe prosody in his work Chandashutrema.

The inhabitants of the island of Mangareva in French Polynesia used a hybrid binary-decimal system until 1450. In the 11th century, the scientist and philosopher Shao Yong developed a method of organizing hexagrams that corresponds to the sequence 0 to 63, as represented in a binary format, with yin being 0 and yang being 1. The order is also a lexicographical order in blocks of elements selected from a two-element set.

New time

In 1605, discussed a system in which the letters of the alphabet could be reduced to sequences of binary digits, which could then be encoded as subtle variations of type in any random text. It is important to note that it was Francis Bacon who supplemented the general theory of binary coding with the observation that this method can be used with any objects.

Another mathematician and philosopher named George Boole published a paper in 1847 called “Mathematical Analysis of Logic,” which described the algebraic system of logic known today as Boolean algebra. The system was based on a binary approach, which consisted of three basic operations: AND, OR and NOT. This system did not become operational until an MIT graduate student named Claude Shannon noticed that the Boolean algebra he was learning was similar to an electrical circuit.

Shannon wrote a dissertation in 1937 that made important findings. Shannon's thesis became the starting point for the use of binary code in practical applications such as computers and electrical circuits.

Other forms of binary code

Bitstring is not the only type of binary code. A binary system in general is any system that allows only two options, such as a switch in an electronic system or a simple true or false test.

Braille is a type of binary code widely used by blind people to read and write by touch, named after its creator Louis Braille. This system consists of grids of six points each, three per column, in which each point has two states: raised or recessed. Different combinations of dots can represent all letters, numbers, and punctuation marks.

American Standard Code for Information Interchange (ASCII) uses a 7-bit binary code to represent text and other characters in computers, communications equipment, and other devices. Each letter or symbol is assigned a number from 0 to 127.

Binary coded decimal or BCD is a binary coded representation of integer values ​​that uses a 4-bit graph to encode decimal digits. Four binary bits can encode up to 16 different values.

In BCD-encoded numbers, only the first ten values ​​in each nibble are valid and encode the decimal digits with zeros after nines. The remaining six values ​​are invalid and may cause either a machine exception or unspecified behavior, depending on the computer's implementation of BCD arithmetic.

BCD arithmetic is sometimes preferred over floating point number formats in commercial and financial applications where complex number rounding behavior is undesirable.

Application

Most modern computers use a binary code program for instructions and data. CDs, DVDs, and Blu-ray Discs represent audio and video in binary form. Telephone calls are carried digitally in long-distance and mobile telephone networks using pulse code modulation and in voice over IP networks.

Binary code decoding is used to translate from machine language to regular language. Online tools work quickly, although it is not difficult to do it manually.

Binary or binary code is used to transmit information digitally. A set of just two characters, such as 1 and 0, allows you to encrypt any information, be it text, numbers or an image.

How to encrypt with binary code

To manually convert any symbols into binary code, tables are used in which each symbol is assigned a binary code in the form of zeros and ones. The most common encoding system is ASCII, which uses 8-bit code notation.

The basic table shows binary codes for the Latin alphabet, numbers and some symbols.

A binary interpretation of the Cyrillic alphabet and additional characters has been added to the extended table.

To convert from binary code to text or numbers, simply select the desired codes from the tables. But, of course, doing this kind of work manually takes a long time. And mistakes, moreover, are inevitable. The computer copes with decryption much faster. And we don’t even think, while typing text on the screen, that at that moment the text is being converted into binary code.

Converting a binary number to decimal

To manually convert a number from a binary number system to a decimal number system, you can use a fairly simple algorithm:

  1. Below the binary number, starting with the rightmost digit, write the number 2 in increasing powers.
  2. The powers of 2 are multiplied by the corresponding digit of the binary number (1 or 0).
  3. Add the resulting values.

This is what this algorithm looks like on paper:

Online services for binary decryption

If you still need to see the decrypted binary code, or, conversely, convert the text into binary form, the easiest way is to use online services designed for these purposes.

Two windows, familiar to online translations, allow you to almost simultaneously see both versions of the text in regular and binary form. And decryption is carried out in both directions. Entering text is a simple matter of copying and pasting.

A single digital signal is not very informative, because it can only take two values: zero and one. Therefore, in cases where it is necessary to transmit, process or store large amounts of information, several parallel digital signals are usually used. Moreover, all these signals should be considered only simultaneously; each of them separately does not make sense. In such cases, we talk about binary codes, that is, codes formed by digital (logical, binary) signals. Each of the logical signals included in the code is called a bit. The more bits included in the code, the more values ​​this code can take.

Unlike the decimal coding of numbers that is familiar to us, that is, a code with a base of ten, with binary coding, the base of the code is the number two (Fig. 2.9). That is, each code digit (each digit) of a binary code can take not ten values ​​(as in decimal code: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9), but only two - 0 and 1. The positional recording system remains the same, that is, the least significant digit is written on the right, and the most significant one on the left. But if in the decimal system the weight of each subsequent digit is ten times greater than the weight of the previous one, then in the binary system (with binary coding) it is twice as large. Each bit of binary code is called a bit (from the English "Binary Digit" - "binary number").

Rice. 2.9. Decimal and binary coding

In table Figure 2.3 shows the correspondence between the first twenty numbers in the decimal and binary systems.

The table shows that the required number of binary code bits is significantly greater than the required number of decimal code bits. The maximum possible number with the number of digits equal to three is 999 in the decimal system, and only 7 in the binary system (that is, 111 in binary code). In general, an n-bit binary number can take on 2n different values, and an n-bit decimal number can take on 10n different values. That is, writing large binary numbers (with more than ten digits) becomes not very convenient.

Table 2.3. Correspondence between numbers in decimal and binary systems
Decimal system Binary system Decimal system Binary system

In order to simplify the recording of binary numbers, the so-called hexadecimal system (hexadecimal coding) was proposed. In this case, all binary bits are divided into groups of four bits (starting with the least significant one), and then each group is encoded with one symbol. Each such group is called nibble(or nibble, notebook), and two groups (8 bits) - byte. From the table 2.3 shows that a 4-bit binary number can take on 16 different values ​​(from 0 to 15). Therefore, the required number of characters for a hexadecimal code is also 16, hence the name of the code. The first 10 characters are the numbers from 0 to 9, and then the 6 initial capital letters of the Latin alphabet are used: A, B, C, D, E, F.

Rice. 2.10. Binary and hexadecimal notation of numbers

In table 2.4 shows examples of hexadecimal encoding of the first 20 numbers (binary numbers are given in brackets), and Fig. Figure 2.10 shows an example of writing a binary number in hexadecimal form. To denote hexadecimal encoding, the letter "h" or "H" (from English Hexadecimal) is sometimes used at the end of a number, for example, the entry A17F h denotes the hexadecimal number A17F. Here A1 represents the high byte of the number and 7F is the low byte of the number. The entire number (in our case, a two-byte number) is called in a word.

Table 2.4. Hexadecimal coding system
Decimal system hexadecimal system Decimal system hexadecimal system
0 (0) A (1010)
1(1) B (1011)
2 (10) C (1100)
3 (11) D (1101)
4 (100) E (1110)
5 (101) F(1111)
6 (110) 10 (10000)
7 (111) 11 (10001)
8 (1000) 12 (10010)
9 (1001) 13 (10011)

To convert a hexadecimal number to a decimal number, you need to multiply the value of the lowest (zero) digit by one, the value of the next (first) digit by 16, the second digit by 256 (16 2), etc., and then add all the products. For example, take the number A17F:

A17F=F*16 0 + 7*16 1 + 1*16 2 + A*16 3 = 15*1 + 7*16+1*256+10*4096=41343

But every digital equipment specialist (developer, operator, repairman, programmer, etc.) needs to learn to handle hexadecimal and binary systems as freely as with regular decimal systems, so that no transfers from system to system are required.

In addition to the codes discussed, there is also the so-called binary-decimal representation of numbers. As in hexadecimal code, in BCD code each digit of the code corresponds to four binary digits, however, each group of four binary digits can take not sixteen, but only ten values, encoded by the characters 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. That is, one decimal place corresponds to four binary ones. As a result, it turns out that writing numbers in binary decimal code is no different from writing in ordinary decimal code (Table 2.6), but in reality it is just a special binary code, each digit of which can take only two values: 0 and 1. BCD code is sometimes very convenient for organizing decimal digital indicators and scoreboards.

Table 2.6. Binary decimal coding system
Decimal system Binary decimal system Decimal system Binary decimal system
0 (0) 10 (1000)
1(1) 11 (1001)
2 (10) 12 (10010)
3 (11) 13 (10011)
4 (100) 14 (10100)
5 (101) 15 (10101)
6 (110) 16 (10110)
7 (111) 17 (10111)
8 (1000) 18 (11000)
9 (1001) 19 (11001)

In binary code, you can perform any arithmetic operations on numbers: addition, subtraction, multiplication, division.

Consider, for example, adding two 4-bit binary numbers. Let us add the number 0111 (decimal 7) and 1011 (decimal 11). Adding these numbers is no more difficult than in decimal notation:

When adding 0 and 0 we get 0, when adding 1 and 0 we get 1, when adding 1 and 1 we get 0 and carry to the next digit 1. The result is 10010 (decimal 18). Adding any two n-bit binary numbers can result in an n-bit number or an (n+1)-bit number.

Subtraction is done in the same way. Let the number 0111 (7) be subtracted from the number 10010 (18). We write the numbers aligned to the least significant digit and subtract in the same way as in the case of the decimal system:

When subtracting 0 from 0 we get 0, when subtracting 0 from 1 we get 1, when subtracting 1 from 1 we get 0, when subtracting 1 from 0 we get 1 and borrow 1 in the next digit. The result is 1011 (decimal 11).

When subtracting, it is possible to obtain negative numbers, so you must use the binary representation of negative numbers.

To simultaneously represent both binary positive and binary negative numbers, the so-called two's complement code is most often used. Negative numbers in this code are expressed by a number that, when added to a positive number of the same value, will result in zero. In order to get a negative number, you need to change all the bits of the same positive number to the opposite ones (0 to 1, 1 to 0) and add 1 to the result. For example, write the number –5. The number 5 in binary code looks like 0101. We replace the bits with the opposite ones: 1010 and add one: 1011. We sum the result with the original number: 1011 + 0101 = 0000 (we ignore the transfer to the fifth digit).

Negative numbers in two's complement code are distinguished from positive numbers by the value of the most significant digit: a one in the most significant digit defines a negative number, and a zero defines a positive number.

In addition to standard arithmetic operations, the binary number system also uses some specific operations, for example, addition modulo 2. This operation (denoted by A) is bitwise, that is, there are no transfers from one digit to another and no borrowing in the highest digits. The rules for addition modulo 2 are as follows: , , . The same operation is called a function Exclusive OR. For example, let's sum modulo 2 two binary numbers 0111 and 1011:

Other bitwise operations on binary numbers include the AND function and the OR function. The AND function results in a one only if the corresponding bits of the two original numbers are both ones, otherwise the result is -0. The OR function results in one when at least one of the corresponding bits of the original numbers is 1, otherwise the result is 0.

The meaning of the term “binary” is that it consists of two parts or components. Thus, binary codes are codes that consist of only two symbolic states, such as black or white, light or dark, conductor or insulator. A binary code in digital technology is a way of representing data (numbers, words, and others) as a combination of two characters, which can be designated as 0 and 1. The characters or units of BC are called bits. One of the justifications for the use of BC is the simplicity and reliability of storing information in any medium in the form of a combination of just two of its physical states, for example, in the form of a change or constancy of the light flux when reading from an optical code disk.
There are various possibilities for encoding information.

Binary code

In digital technology, a method of representing data (numbers, words, and others) as a combination of two characters, which can be designated as 0 and 1. The signs or units of the DC are called bits.

One of the justifications for the use of DC is the simplicity and reliability of storing information in any medium in the form of a combination of just two of its physical states, for example, in the form of a change or constancy of the magnetic flux in a given cell of the magnetic recording medium.

The largest number that can be expressed in binary depends on the number of digits used, i.e. on the number of bits in the combination expressing the number. For example, to express the numeric values ​​from 0 to 7, it is enough to have a 3-digit or 3-bit code:

numeric value binary code
0 000
1 001
2 010
3 011
4 100
5 101
6 110
7 111

From this we can see that for a number greater than 7 with a 3-digit code there are no longer code combinations of 0 and 1.

Moving from numbers to physical quantities, let us formulate the above statement in a more general form: the largest number of values ​​m of any quantity (temperature, voltage, current, etc.), which can be expressed in binary code, depends on the number of bits n used as m= 2n. If n=3, as in the example considered, then we get 8 values, including leading 0.
Binary code is a multi-step code. This means that when moving from one position (value) to another, several bits can change simultaneously. For example, the number 3 in binary code = 011. The number 4 in binary code = 100. Accordingly, when moving from 3 to 4, all 3 bits change their state to the opposite simultaneously. Reading such a code from a code disk would lead to the fact that, due to inevitable deviations (tolerances) during the production of a code disk, a change in information from each of the tracks separately will never occur simultaneously. This in turn would lead to the fact that when moving from one number to another, incorrect information would be briefly given. So, during the above-mentioned transition from the number 3 to the number 4, a short-term output of the number 7 is very likely when, for example, the most significant bit during the transition changed its value a little earlier than the rest. To avoid this, a so-called one-step code is used, for example the so-called Gray Code.

Gray code

Gray code is a so-called one-step code, i.e. When moving from one number to another, only one of all bits of information always changes. An error when reading information from a mechanical code disk when moving from one number to another will only lead to the fact that the transition from one position to another will be only slightly shifted in time, but the issuance of a completely incorrect angular position value when moving from one position to another is completely eliminated .
Another advantage of Gray Code is its ability to mirror information. So, by inverting the most significant bit, you can simply change the direction of counting and thus match the actual (physical) direction of rotation of the axis. Changing the counting direction in this way can be easily changed by controlling the so-called “Complement” input. The output value can thus be increasing or decreasing for the same physical direction of rotation of the axis.
Since the information expressed in Gray Code is purely encoded in nature and does not carry real numerical information, it must first be converted into a standard binary code before further processing. This is done using a code converter (Gray-Binar decoder), which, fortunately, is easily implemented using a circuit of exclusive-or (XOR) logic elements, both in software and in hardware.

Corresponding decimal numbers in the range from 0 to 15 to binary and Gray codes

Binary coding Gray coding
Decimal code
Binary value Sixteen meaning Decimal code Binary value Sixteen meaning
0 0000 0h 0 0000 0h
1 0001 1h 1 0001 1h
2 0010 2h 3 0011 3h
3 0011 3h 2 0010 2h
4 0100 4h 6 0110 6h
5 0101 5h 7 0111 7h
6 0110 6h 5 0101 5h
7 0111 7h 4 0100 4h
8 1000 8h 12 1100 Ch
9 1001 9h 13 1101 Dh
10 1010 Ah 15 1111 Fh
11 1011 Bh 14 1110 Eh
12 1100 Ch 10 1010 Ah
13 1101 Dh 11 1011 Bh
14 1110 Eh 9 1001 9h
15 1111 Fh 8 1000 8h

Converting the Gray code to the usual binary code can be done using a simple circuit with inverters and exclusive-or gates as shown below:

Code Gray-Excess

The usual one-step Gray code is suitable for resolutions that can be represented as a number raised to the power of 2. In cases where it is necessary to implement other permissions, the middle section is cut out from the regular Gray code and used. This way the code remains “one-step”. However, the numeric range does not start at zero, but is shifted by a certain value. When processing information, half the difference between the original and reduced resolution is subtracted from the generated signal. Resolutions such as 360? to express an angle are often implemented by this method. So a 9-bit Gray code equal to 512 steps, trimmed on both sides by 76 steps, will be equal to 360°.

Because it is the simplest and meets the requirements:

  • The fewer values ​​there are in the system, the easier it is to manufacture individual elements that operate on these values. In particular, two digits of the binary number system can be easily represented by many physical phenomena: there is a current - there is no current, the magnetic field induction is greater than a threshold value or not, etc.
  • The fewer states an element has, the higher the noise immunity and the faster it can operate. For example, to encode three states through the magnitude of the magnetic field induction, you will need to enter two threshold values, which will not contribute to noise immunity and reliability of information storage.
  • Binary arithmetic is quite simple. Simple are the tables of addition and multiplication - the basic operations with numbers.
  • It is possible to use the apparatus of logical algebra to perform bitwise operations on numbers.

Links

  • Online calculator for converting numbers from one number system to another

Wikimedia Foundation. 2010.

See what “Binary code” is in other dictionaries:

    2-bit Gray code 00 01 11 10 3-bit Gray code 000 001 011 010 110 111 101 100 4-bit Gray code 0000 0001 0011 0010 0110 0111 0101 0100 1100 1101 1111 111 0 1010 1011 1001 1000 Gray code a number system in which two adjacent values ... ... Wikipedia

    Signal Point Code (SPC) of Signal System 7 (SS7, OX 7) is a unique (in the home network) node address used at the third MTP level (routing) in telecommunication OX 7 networks for identification ... Wikipedia

    In mathematics, a square-free number is a number that is not divisible by any square except 1. For example, 10 is square-free, but 18 is not, since 18 is divisible by 9 = 32. The beginning of the sequence of square-free numbers is: 1, 2, 3, 5, 6, 7,… … Wikipedia

    To improve this article, would you like to: Wikify the article. Rework the design in accordance with the rules for writing articles. Correct the article according to Wikipedia stylistic rules... Wikipedia

    This term has other meanings, see Python (meanings). Python Language class: mu... Wikipedia

    In the narrow sense of the word, the phrase currently means “Attempt on a security system,” and is more inclined to the meaning of the following term, Cracker attack. This happened due to a distortion of the meaning of the word “hacker” itself. Hacker... ...Wikipedia