Computers Windows Internet

As in the binary code will be the word hello. Russian alphabet in binary code. Uniform alphabetic binary coding. Byte code. Understanding binary numbers

The term "binary" in the sense - consisting of two parts, 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) in the form of a combination of two characters, which can be designated as 0 and 1. BC characters or units are called bits. One of the justifications for the use of BC is the simplicity and reliability of information accumulation in any medium in the form of a combination of only two of its physical states, for example, in the form of a change or constancy of the luminous 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 characters or units of the DC are called bits.

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

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

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

From this it can be seen that for a number greater than 7 with a 3-bit code, there are no more code combinations of 0 and 1.

Passing from numbers to physical quantities, we will formulate the above statement in more general view: the largest number of values ​​m of any quantity (temperature, voltage, current, etc.) that can be expressed in binary code depends on the number of bits used n as m = 2n. If n = 3, as in the considered example, then we get 8 values, including the leading 0.
Binary code is multi-step code. This means that when moving from one position (value) to another, several bits can change at the same time. For example, the number 3 in binary code= 011. The number 4 in the binary code = 100. Accordingly, when passing from 3 to 4, all 3 bits change their state to the opposite one at the same time. Reading such a code from the code disc would lead to the fact that, due to inevitable deviations (tolerances) in the production of the code disc, the change in information from each of the tracks separately will never occur simultaneously. This, in turn, would lead to the fact that during the transition from one number to another, incorrect information would be displayed for a short time. So with the aforementioned 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

The gray code is the so-called one-step code, i.e. when moving from one number to another, only one of all the bits of information always changes. An error in 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 only be slightly shifted in time, however, the issuance of a completely incorrect value of the angular position when moving from one position to another is completely excluded ...
The advantage of the Gray Code is also its ability to mirror information. So by inverting the most significant bit, you can simply change the direction of counting and thus adjust to the actual (physical) direction of rotation of the axis. Changing the counting direction in this way can be easily changed by manipulating the so-called "Complement" input. The returned value can thus be rising or falling for the same physical direction of rotation of the axis.
Since the information expressed in Gray-code is purely coded, it is not a real carrier numerical information it must first be converted to standard binary before further processing. This is done using a code converter (Gray-Binar decoder) which, fortunately, is easily implemented using a chain of logical elements "exclusive or" (XOR) both in software and hardware.

Matching decimal numbers in the range from 0 to 15 to binary and gray codes

Binary encoding 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 into a familiar binary code can be done using simple scheme with inverters and “exclusive-or” gates as shown below:

Gray-Excess Code

The usual one-step Gray code is suitable for resolutions that can be represented as a number raised to a power of 2. In cases where it is necessary to implement other resolutions from the usual Gray code, its middle section is cut out and used. Thus, the "one-step" code is preserved. However, the numeric range does not start at zero, but is offset by a specific 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 °.

Computers don't understand words and numbers the way humans do. Modern software allows the end user to ignore it, but at the lowest levels your computer operates on a binary electrical signal that has only two states: whether there is current or not. To "understand" complex data, your computer must encode it in binary.

The binary system is based on two digits, 1 and 0, which correspond to the on and off states that your computer can understand. You are probably familiar with the decimal system. It uses ten digits, from 0 to 9, and then moves on to the next order to form two-digit numbers, with a digit from each next order ten times larger than the previous one. The binary system is similar, with each digit twice as large as the previous one.

Counting in binary

In binary, the first digit is the decimal 1. The second digit is 2, the third is 4, the fourth is 8, and so on - it doubles each time. Adding all of these values ​​will give you a decimal number.

1111 (binary) = 8 + 4 + 2 + 1 = 15 (decimal)

Accounting 0 gives us 16 possible values ​​for four binary bits. Move 8 bits and you get 256 possible values. This takes a lot more space to represent, since four digits in decimal give us 10,000 possible values. Of course, binary code takes up more space, but computers understand binaries much better than decimal. And for some things, like logical processing, binary is better than decimal.

It should be said that there is another basic system that is used in programming: hexadecimal... Although computers do not work in hexadecimal format, programmers use it to represent binary addresses in a human-readable format when they write code. This is because two digits of a hexadecimal number can represent a whole byte, that is, they replace eight digits in binary. The hexadecimal system uses the numbers 0-9 and the letters A through F to give an additional six digits.

Why computers use binaries

The short answer is: Hardware and the laws of physics. Every character in your computer is an electrical signal, and in the early days of computing, electrical signals were much more difficult to measure. It made more sense to distinguish between only the “on” state, represented by a negative charge, and the “off” state, represented by a positive charge.

For those who do not know why "off" is represented by a positive charge, this is due to the fact that electrons have a negative charge, and more electrons - more current with a negative charge.

Thus, early room-sized computers used binaries to build their systems, and although they used older, more cumbersome hardware, they operated on the same fundamental principles. Modern computers use the so-called transistor to perform calculations with binary code.

Here is a diagram of a typical transistor:

Essentially, it allows current to flow from source to drain if there is current in the gate. This forms a binary key. Manufacturers can make these transistors incredibly small - as small as 5 nanometers or the size of two strands of DNA. This is how they work modern processors, and even they can suffer from problems distinguishing between on and off states (although this is due to their unrealistic molecular size, subject to oddities of quantum mechanics).

Why only binary system

So you might be thinking, “Why only 0 and 1? Why not add one more number? " While this is partly due to the tradition of making computers, adding another digit would mean that there is another state of current to be highlighted, not just off or on.

The problem here is that if you want to use multiple voltage levels, you need a way to easily compute with them, and modern hardware capable of doing this is not viable as a replacement for binary computation. For example, there is a so-called triple computer developed in the 1950s, but development stopped there. Ternary logic more efficient than binary, but there is still no effective replacement for binary transistor, or at least there is no transistor as tiny in scale as binary.

The reason why we cannot use triple logic comes down to how transistors are connected in a computer and how they are used for mathematical calculations. The transistor receives information on two inputs, performs an operation and returns the result to one output.

Thus, binary mathematics is easier on the computer than anything else. Binary logic is easily converted to binary systems, with True and False corresponding to On and Off states.

A binary truth table operating on binary logic will have four possible outputs for each fundamental operation. But, since the triple gate uses three entrances, the triple truth table would have 9 or more. While the binary system has 16 possible operators (2 ^ 2 ^ 2), the ternary system would have 19683 (3 ^ 3 ^ 3). Scaling becomes an issue because, while ternary is more efficient, it is also exponentially more complex.

Who knows? In the future, it is quite possible that we will see trigeminal computers, since binary logic faced problems of miniaturization. For now, the world will continue to operate in binary mode.

I decided to make such a tool as converting text to binary code and vice versa, there are such services, but they usually work with the Latin alphabet, mine is the translator works with unicode encoding UTF-8 format which encodes Cyrillic characters in two bytes. this moment the translator's capabilities are limited to double-byte encodings, i.e. Chinese characters cannot be broadcast, but I'm going to correct this annoying misunderstanding.

To convert text to binary enter text in the left window and press TEXT-> BIN in the right window its binary representation will appear.

To convert binary code to text enter the code in the right window and press BIN-> TEXT in the left window its symbolic representation will appear.

If translation of binary code into text or vice versa, it did not work out - check the correctness of your data!

Update!

The reverse transformation of the type text is now available:

into a normal view. To do this, check the box: "Replace 0 with spaces, and 1 with █". Then paste the text into the right window: "Text in binary representation" and click the button under it "BIN-> TEXT".

When copying such texts, you need to be careful because you can easily lose spaces at the beginning or at the end. For example, the line above looks like this:

██ █ █ ███████ █ ██ ██ █ █ ███ ██ █ █ ██ █ ██ █ █ ██ █ ███ █ ██ █ █ ██ █ █ ███ ██ █ █ ███ ██ █ ██

and on a red background:

██ █ █ ███████ █ ██ ██ █ █ ███ ██ █ █ ██ █ ██ █ █ ██ █ ███ █ ██ █ █ ██ █ █ ███ ██ █ █ ███ ██ █ ██

see how many spaces at the end you can lose?

The set of characters with which text is written is called alphabet.

The number of characters in the alphabet is his power.

Formula for determining the amount of information: N = 2 b,

where N is the cardinality of the alphabet (number of characters),

b is the number of bits (informational weight of the character).

The 256-character alphabet can accommodate almost all the characters you need. This alphabet is called sufficient.

Because 256 = 2 8, then the weight of 1 character is 8 bits.

The 8-bit unit was named 1 byte:

1 byte = 8 bits.

The binary code of each character in computer text takes up 1 byte of memory.

How is text information represented in computer memory?

The convenience of byte encoding of characters is obvious, since a byte is the smallest addressable part of memory and, therefore, the processor can access each character separately, performing text processing. On the other hand, 256 characters is quite a sufficient number to represent a wide variety of character information.

Now the question arises, what kind of eight-bit binary code to assign to each character.

It is clear that this is a conditional matter, you can come up with many encoding methods.

All characters in the computer alphabet are numbered from 0 to 255. Each number corresponds to an eight-digit binary code from 00000000 to 11111111. This code is simply the ordinal number of a character in the binary system.

The table in which all the characters of the computer alphabet are assigned serial numbers is called the encoding table.

For different types Computers use various coding tables.

The international standard for the PC has become the table ASCII(read asci) (American Standard Code for Information Interchange).

The ASCII table is divided into two parts.

The international standard is only the first half of the table, i.e. symbols with numbers from 0 (00000000), up to 127 (01111111).

ASCII encoding table structure

Serial number

Code

Symbol

0 - 31

00000000 - 00011111

Symbols with numbers from 0 to 31 are usually called control characters.
Their function is to control the process of displaying text on the screen or printing, feeding sound signal, text markup, etc.

32 - 127

00100000 - 01111111

Standard part of the table (English). This includes lowercase and uppercase letters Latin alphabet, decimal digits, punctuation marks, all kinds of brackets, commercial and other symbols.
Character 32 is a space, i.e. empty position in the text.
All others are reflected in certain signs.

128 - 255

10000000 - 11111111

Alternative part of the table (Russian).
The second half of the ASCII code table, called the code page (128 codes, starting with 10000000 and ending with 11111111), can have different variants, each variant has its own number.
The code page is primarily used to accommodate national alphabets other than Latin. In Russian national encodings, this part of the table contains symbols of the Russian alphabet.

The first half of the ASCII table


I draw your attention to the fact that in the encoding table, letters (uppercase and lowercase) are arranged in alphabetical order, and numbers are ordered in ascending order of values. This observance of the lexicographic order in the arrangement of characters is called the principle of sequential coding of the alphabet.

For the letters of the Russian alphabet, the principle of sequential coding is also observed.

The second half of the ASCII table


Unfortunately, there are currently five different Cyrillic encodings (KOI8-R, Windows. MS-DOS, Macintosh and ISO). Because of this, problems often arise with the transfer of Russian text from one computer to another, from one software system to another.

Chronologically, one of the first standards for encoding Russian letters on computers was KOI8 ("Information exchange code, 8-bit"). This encoding was used back in the 70s on computers of the ES EVM series, and from the mid 80s it began to be used in the first Russified versions. operating system UNIX.

From the beginning of the 90s, the time of the dominance of the MS DOS operating system, the CP866 encoding remains ("CP" stands for "Code Page").

Apple computers running Mac OS use their own Mac encoding.

In addition, the International Organization for Standardization (International Standards Organization, ISO) approved another encoding called ISO 8859-5 as a standard for the Russian language.

The most common currently is Microsoft encoding Windows, abbreviated as CP1251.

Since the late 90s, the problem of character coding standardization has been solved by the introduction of a new international standard called Unicode... This is a 16-bit encoding i.e. it allocates 2 bytes of memory for each character. Of course, this doubles the amount of memory used. But then such code table can include up to 65536 characters. Full specification Unicode standard includes all existing, extinct and artificially created alphabets of the world, as well as many mathematical, musical, chemical and other symbols.

Let's try to use an ASCII table to imagine how words will look in computer memory.

Internal representation of words in computer memory

Sometimes it happens that a text consisting of letters of the Russian alphabet, received from another computer, cannot be read - some kind of "gibberish" is visible on the monitor screen. This is due to the fact that computers use different encoding of the characters of the Russian language.

Binary code decoding is used to translate from machine language to ordinary. Online tools work quickly, although it's easy to do it manually.

Binary or binary code is used to transmit information in digital form. A set of only two characters, for example 1 and 0, allows you to encrypt any information, be it text, numbers or an image.

How to encrypt with binary code

For manual translation of any symbols into a 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 base table contains 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 translate from a binary code into text or numbers, it is enough to select the desired codes from the tables. But, of course, it takes a long time to do such work manually. And mistakes, moreover, are inevitable. The computer copes with decryption much faster. And we do not even think, typing on the screen text, that at this moment the text is being translated into a binary code.

Converting a binary number to decimal

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

  1. Below a binary number, starting from the extreme right digit, write the number 2 in increasing degrees.
  2. Multiply the powers of the number 2 by the corresponding digit of the binary number (1 or 0).
  3. Add the resulting values.

This is how the algorithm looks on paper:

Online services for binary decryption

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

Two windows, usual for online translations, allow you to see both versions of the text in normal and binary form almost simultaneously. And decryption is carried out in both directions. Entering text is done by simple copying and pasting.