Hello in binary code. Converting text into digital code
The set of characters with which text is written is called alphabet.
The number of characters in the alphabet is its power.
Formula for determining the amount of information: N=2b,
where N is the power of the alphabet (number of characters),
b – number of bits (information weight of the symbol).
The alphabet with a capacity of 256 characters can accommodate almost all the necessary characters. This alphabet is called sufficient.
Because 256 = 2 8, then the weight of 1 character is 8 bits.
The unit of measurement 8 bits was given the name 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-by-byte character encoding is obvious because a byte is the smallest addressable part of memory and, therefore, the processor can access each character separately when processing text. On the other hand, 256 characters is quite a sufficient number to represent a wide variety of symbolic information.
Now the question arises, which 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-bit binary code from 00000000 to 11111111. This code is simply the serial number of the character in binary system Reckoning.
A table in which all characters of the computer alphabet are assigned serial numbers is called an encoding table.
For different types Computers use different encoding tables.
The table has become the international standard for PCs ASCII(read aski) (American standard code For information exchange).
The ASCII code table is divided into two parts.
Only the first half of the table is the international standard, 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 symbols. |
32 - 127 |
00100000 - 01111111 |
Standard part of the table (English). This includes lowercase and uppercase letters of the Latin alphabet, decimal numbers, punctuation marks, all kinds of parentheses, commercial and other symbols. |
128 - 255 |
10000000 - 11111111 |
Alternative part of the table (Russian). |
First half of the ASCII code table
![]() |
I draw your attention to the fact that in the encoding table the letters (uppercase and lowercase) are located in alphabetical order, and the numbers are ordered in ascending order. This observance of lexicographic order in the arrangement of symbols is called the principle of sequential coding of the alphabet.
For letters of the Russian alphabet, the principle of sequential coding is also observed.
Second half of the ASCII code table
![](https://i0.wp.com/school497.ru/download/u/02/img/asc1.gif)
Unfortunately, there are currently five different Cyrillic encodings (KOI8-R, Windows. MS-DOS, Macintosh and ISO). Because of this, problems often arise with transferring 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 computer series, and from the mid-80s it began to be used in the first Russified versions operating system UNIX.
From the early 90s, the time of dominance of the MS DOS operating system, the CP866 encoding remains ("CP" means "Code Page", "code page").
Computers Apple operating under operating room control Mac systems OS, use their own Mac encoding.
In addition, the International Standards Organization (ISO) has approved another encoding called ISO 8859-5 as a standard for the Russian language.
The most common encoding currently used is Microsoft Windows, abbreviated CP1251.
Since the late 90s, the problem of standardizing character encoding has been solved by introducing a new international standard which is called Unicode. This is a 16-bit encoding, i.e. it allocates 2 bytes of memory for each character. Of course, this increases the amount of memory occupied by 2 times. But such a code table allows the inclusion of up to 65536 characters. The complete specification of the Unicode standard includes all the existing, extinct and artificially created alphabets of the world, as well as many mathematical, musical, chemical and other symbols.
Let's try using an ASCII table to imagine what words will look like in the computer's 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 “abracadabra” is visible on the monitor screen. This happens because computers use different character encodings for the Russian language.
Purpose of the service. The service is designed to convert numbers from one number system to another in online mode. To do this, select the base of the system from which you want to convert the number. You can enter both integers and numbers with commas.You can enter both whole numbers, for example 34, and fractional numbers, for example, 637.333. For fractional numbers, the translation accuracy after the decimal point is indicated.
The following are also used with this calculator:
Ways to represent numbers
Binary (binary) numbers - each digit means the value of one bit (0 or 1), the most significant bit is always written on the left, the letter “b” is placed after the number. For ease of perception, notebooks can be separated by spaces. For example, 1010 0101b.Hexadecimal (hexadecimal) numbers - each tetrad is represented by one symbol 0...9, A, B, ..., F. This representation can be designated in different ways, here only the symbol “h” is used after the last hexadecimal digit. For example, A5h. In program texts, the same number can be designated as either 0xA5 or 0A5h, depending on the syntax of the programming language. A leading zero (0) is added to the left of the most significant hexadecimal digit represented by the letter to distinguish between numbers and symbolic names.
Decimal (decimal) numbers - each byte (word, double word) is represented by an ordinary number, and the decimal representation sign (the letter “d”) is usually omitted. The byte in the previous examples has a decimal value of 165. Unlike binary and hexadecimal notation, decimal is difficult to mentally determine the value of each bit, which is sometimes necessary.
Octal (octal) numbers - each triple of bits (division starts from the least significant) is written as a number 0–7, with an “o” at the end. The same number would be written as 245o. The octal system is inconvenient because the byte cannot be divided equally.
Algorithm for converting numbers from one number system to another
Converting whole decimal numbers to any other number system is carried out by dividing the number by the base new system numbering until the remainder remains a number smaller than the base of the new number system. The new number is written as division remainders, starting from the last one.Converting a regular decimal fraction to another PSS is carried out by multiplying only the fractional part of the number by the base of the new number system until all zeros remain in the fractional part or until the specified translation accuracy is achieved. As a result of each multiplication operation, one digit of a new number is formed, starting with the highest one.
Improper fraction translation is carried out according to rules 1 and 2. The integer and fractional parts are written together, separated by a comma.
Example No. 1.
Conversion from 2 to 8 to 16 number system.
These systems are multiples of two, therefore the translation is carried out using a correspondence table (see below).
To convert a number from the binary number system to the octal (hexadecimal) number system, it is necessary to divide the binary number from the decimal point to the right and left into groups of three (four for hexadecimal) digits, supplementing the outer groups with zeros if necessary. Each group is replaced by the corresponding octal or hexadecimal digit.
Example No. 2. 1010111010.1011 = 1.010.111.010.101.1 = 1272.51 8
here 001=1; 010=2; 111=7; 010=2; 101=5; 001=1
When converting to the hexadecimal system, you must divide the number into parts of four digits, following the same rules.
Example No. 3. 1010111010,1011 = 10.1011.1010,1011 = 2B12,13 HEX
here 0010=2; 1011=B; 1010=12; 1011=13
Converting numbers from 2, 8 and 16 to the decimal system is done by breaking the number into individual ones and multiplying it by the base of the system (from which the number is translated) raised to the power corresponding to it serial number in the translated number. In this case, the numbers are numbered to the left of the decimal point (the first number is numbered 0) with increasing, and to the right with decreasing (i.e., with a negative sign). The results obtained are added up.
Example No. 4.
An example of conversion from binary to decimal number system.
1010010.101 2 = 1·2 6 +0·2 5 +1·2 4 +0·2 3 +0·2 2 +1·2 1 +0·2 0 + 1·2 -1 +0·2 - 2 +1 2 -3 =
= 64+0+16+0+0+2+0+0.5+0+0.125 = 82.625 10 An example of conversion from octal to decimal number system. 108.5 8 = 1*·8 2 +0·8 1 +8·8 0 + 5·8 -1 = 64+0+8+0.625 = 72.625 10 An example of conversion from hexadecimal to decimal number system. 108.5 16 = 1·16 2 +0·16 1 +8·16 0 + 5·16 -1 = 256+0+8+0.3125 = 264.3125 10
Once again we repeat the algorithm for converting numbers from one number system to another PSS
- From the decimal number system:
- divide the number by the base of the number system being translated;
- find the remainder when dividing an integer part of a number;
- write down all remainders from division in reverse order;
- From the binary number system
- To convert to the decimal number system, it is necessary to find the sum of the products of base 2 by the corresponding degree of digit;
- To convert a number to octal, you need to break the number into triads.
For example, 1000110 = 1,000 110 = 106 8 - To convert a number from binary to hexadecimal, you need to divide the number into groups of 4 digits.
For example, 1000110 = 100 0110 = 46 16
Number system correspondence table:
Binary SS | Hexadecimal SS |
0000 | 0 |
0001 | 1 |
0010 | 2 |
0011 | 3 |
0100 | 4 |
0101 | 5 |
0110 | 6 |
0111 | 7 |
1000 | 8 |
1001 | 9 |
1010 | A |
1011 | B |
1100 | C |
1101 | D |
1110 | E |
1111 | F |
Table for conversion to octal number system
08. 06.2018
Blog of Dmitry Vassiyarov.
Binary code - where and how is it used?
Today I am especially glad to meet you, my dear readers, because I feel like a teacher who, at the very first lesson, begins to introduce the class to letters and numbers. And since we live in a world of digital technology, I will tell you what binary code is, which is their basis.
Let's start with the terminology and find out what binary means. For clarification, let’s return to our usual calculus, which is called “decimal”. That is, we use 10 characters and numbers, which make it possible to conveniently operate different numbers and keep appropriate records. Following this logic, the binary system provides for the use of only two characters. In our case, these are just “0” (zero) and “1” one. And here I want to warn you that hypothetically there could be others in their place symbols, but it is precisely these values, indicating the absence (0, empty) and the presence of a signal (1 or “stick”), that will help us further understand the structure of the binary code.
Why is binary code needed?
Before the advent of computers, various automatic systems, the operating principle of which is based on receiving a signal. The sensor is triggered, the circuit is closed and a certain device is turned on. No current in the signal circuit - no operation. It was electronic devices that made it possible to achieve progress in processing information represented by the presence or absence of voltage in a circuit.
Their further complication led to the emergence of the first processors, which also did their job, processing a signal consisting of pulses alternating in a certain way. We will not delve into the program details now, but the following is important for us: electronic devices turned out to be able to distinguish a given sequence of incoming signals. Of course, it is possible to describe the conditional combination this way: “there is a signal”; "no signal"; “there is a signal”; “there is a signal.” You can even simplify the notation: “there is”; "No"; "There is"; "There is".
But it is much easier to denote the presence of a signal with a unit “1”, and its absence with a zero “0”. Then we can use a simple and concise binary code instead: 1011.
Of course, processor technology has stepped far forward and now chips are able to perceive not just a sequence of signals, but entire programs written with specific commands consisting of individual characters. But to record them, the same binary code is used, consisting of zeros and ones, corresponding to the presence or absence of a signal. Whether he exists or not, it doesn’t matter. For a chip, any of these options is a single piece of information, which is called a “bit” (bit is the official unit of measurement).
Conventionally, a symbol can be encoded as a sequence of several characters. Two signals (or their absence) can describe only four options: 00; 01;10; 11. This encoding method is called two-bit. But it can also be:
- four-bit (as in the example in the paragraph above 1011) allows you to write 2^4 = 16 character combinations;
- eight-bit (for example: 0101 0011; 0111 0001). At one time it was of greatest interest to programming because it covered 2^8 = 256 values. This made it possible to describe all decimal digits, the Latin alphabet and special characters;
- sixteen-bit (1100 1001 0110 1010) and higher. But records with such a length are already for modern, more complex tasks. Modern processors use 32 and 64-bit architecture;
I'll be honest, I'm the only one official version no, it so happened that it was the combination of eight characters that became the standard measure of stored information called a “byte”. This could be applied even to one letter written in 8-bit binary code. So, my dear friends, please remember (if anyone didn’t know):
8 bits = 1 byte.
That's how it is. Although a character written with a 2 or 32-bit value can also nominally be called a byte. By the way, thanks to binary code we can estimate the volume of files measured in bytes and the speed of information and Internet transmission (bits per second).
Binary encoding in action
To standardize the recording of information for computers, several coding systems have been developed, one of which, ASCII, based on 8-bit recording, has become widespread. The values in it are distributed in a special way:
- the first 31 characters are control characters (from 00000000 to 00011111). Serve for service commands, output to a printer or screen, sound signals, text formatting;
- the following from 32 to 127 (00100000 – 01111111) Latin alphabet and auxiliary symbols and punctuation marks;
- the rest, up to the 255th (10000000 – 11111111) – alternative, part of the table for special tasks and displaying national alphabets;
The decoding of the values in it is shown in the table.
If you think that “0” and “1” are located in a chaotic order, then you are deeply mistaken. Using any number as an example, I will show you a pattern and teach you how to read numbers written in binary code. But for this we will accept some conventions:
- we will read a byte of 8 characters from right to left;
- if in ordinary numbers We use the digits of ones, tens, hundreds, then here (reading in reverse order) for each bit various powers of “two” are presented: 256-124-64-32-16-8- 4-2-1;
- Now we look at the binary code of the number, for example 00011011. Where there is a “1” signal in the corresponding position, we take the values of this bit and sum them up in the usual way. Accordingly: 0+0+0+32+16+0+2+1 = 51. Correct this method you can verify by looking at the code table.
Now, my inquisitive friends, you not only know what binary code is, but also know how to convert the information encrypted by it.
Language understandable to modern technology
Of course, the algorithm for reading binary code by processor devices is much more complicated. But you can use it to write down anything you want:
- text information with formatting options;
- numbers and any operations with them;
- graphic and video images;
- sounds, including those beyond our hearing range;
In addition, due to the simplicity of the “presentation” it is possible various ways recording binary information: HDD disks;
Complements the benefits binary coding practically unlimited possibilities for transmitting information over any distance. This is the method of communication used with spacecraft and artificial satellites.
So, today the binary number system is a language that is understood by most of us. electronic devices. And what’s most interesting is that no other alternative is foreseen for now.
I think that the information I have presented will be quite enough for you to get started. And then, if such a need arises, everyone can delve deeper into self-study this topic. I will say goodbye and after a short break I will prepare for you a new article on my blog on some interesting topic.
It's better if you tell me it yourself ;)
See you soon.
Because it is the simplest and meets the requirements:
- The fewer values exist in the system, the easier it is to produce individual elements, operating with these values. In particular, two digits of the binary number system can be easily represented by many physical phenomena: there is current - no current, induction magnetic field greater than the 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 11 10 1010 1011 1001 1000 Gray code a number system in which two adjacent values ... ... Wikipedia
Signal Point Code (SPC) of signal system 7 (SS7, OKS 7) is unique (in home network) host address used at the third level of MTP (routing) in telecommunications SS7 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 tends rather 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
Everyone knows that computers can perform calculations with in large groups data at enormous speed. But not everyone knows that these actions depend on only two conditions: whether there is current or not and what voltage.
How does a computer manage to process such a variety of information?
The secret lies in the binary number system. All data enters the computer, presented in the form of ones and zeros, each of which corresponds to one state of the electrical wire: units - high voltage, zeros - low or ones - the presence of voltage, zeros - its absence. Converting data into zeros and ones is called binary conversion, and its final designation is called binary code.
In decimal notation based on decimal system In calculus, which is used in everyday life, a numerical value is represented by ten digits from 0 to 9, and each place in the number has a value ten times higher than the place to the right of it. To represent a number greater than nine in the decimal system, a zero is placed in its place, and a one is placed in the next, more valuable place to the left. Similarly, in the binary system, which uses only two digits - 0 and 1, each place is twice as valuable as the place to the right of it. Thus, in binary code Only zero and one can be represented as single numbers, and any number greater than one requires two places. After zero and one, the next three binary numbers these are 10 (read one-zero) and 11 (read one-one) and 100 (read one-zero-zero). 100 binary is equivalent to 4 decimal. The top table on the right shows other BCD equivalents.
Any number can be expressed in binary, it just takes more space than in decimal notation. The alphabet can also be written in the binary system if a certain binary number is assigned to each letter.
Two figures for four places
16 combinations can be made using dark and light balls, combining them in sets of four. If dark balls are taken as zeros and light balls as ones, then 16 sets will turn out to be a 16-unit binary code, the numerical value of which is from zero to five ( see top table on page 27). Even with two types of balls in the binary system, an infinite number of combinations can be built simply by increasing the number of balls in each group - or the number of places in the numbers.
Bits and bytes
The smallest unit in computer processing, a bit is a unit of data that can have one of two possible conditions. For example, each of the ones and zeros (on the right) represents 1 bit. A bit can be represented in other ways: by presence or absence electric current, a hole and its absence, the direction of magnetization to the right or left. Eight bits make up a byte. 256 possible bytes can represent 256 characters and symbols. Many computers process one byte of data at a time.
Binary conversion. Four-digit binary code can represent decimal numbers from 0 to 15.
Code tables
When binary code is used to represent letters of the alphabet or punctuation marks, code tables are required that indicate which code corresponds to which character. Several such codes have been compiled. Most PCs are designed for seven digital code, called ASCII, or American Standard Code for Information Interchange. The table on the right shows ASCII codes for the English alphabet. Other codes are for thousands of characters and alphabets of other languages of the world.
Part of an ASCII code table