• Number systems. The positional number system is hexadecimal. Binary octal hexadecimal number system

    To represent numbers in a microprocessor it is used binary number system.
    Moreover, any digital signal can have two stable states: " high level" And " low level" In the binary number system, two digits are used to represent any number, respectively: 0 and 1. Arbitrary number x=a n a n-1 ..a 1 a 0 ,a -1 a -2 …a -m will be written in binary number system as

    x = a n ·2 n +a n-1 ·2 n-1 +…+a 1 ·2 1 +a 0 ·2 0 +a -1 ·2 -1 +a -2 ·2 -2 +…+a -m ·2 -m

    Where a i— binary digits (0 or 1).

    Octal number system

    IN octal system In numbering, the basic digits are numbers from 0 to 7. 8 units of the lowest digit are combined into a unit of the highest digit.

    Hexadecimal number system

    In the hexadecimal number system, the base digits are the numbers from 0 to 15 inclusive. To designate base digits greater than 9 with one symbol, in addition to the Arabic numerals 0...9 in the hexadecimal number system, letters of the Latin alphabet are used:

    10 10 = A 16 12 10 = C 16 14 10 = E 16
    11 10 = B 16 13 10 = D 16 15 10 = F 16.

    For example, the number 175 10 in hexadecimal number system will be written as AF 16. Really,

    10·16 1 +15·16 0 =160+15=175

    The table shows numbers from 0 to 16 in decimal, binary, octal and hexadecimal number systems.

    Decimal Binary Octal Hexadecimal
    0 0 0 0
    1 1 1 1
    2 10 2 2
    3 11 3 3
    4 100 4 4
    5 101 5 5
    6 110 6 6
    7 111 7 7
    8 1000 10 8
    9 1001 11 9
    10 1010 12 A
    11 1011 13 B
    12 1100 14 C
    13 1101 15 D
    14 1110 16 E
    15 1111 17 F
    16 10000 20 10

    Binary-octal and binary-hexadecimal conversions

    The binary number system is convenient for performing arithmetic operations using microprocessor hardware, but is inconvenient for human perception because it requires large quantity discharges. Therefore, in computer technology in addition to the binary number system, octal and hexadecimal system Numbers for a more compact representation of numbers.

    The three digits of the octal number system implement all possible combinations of octal digits in the binary number system: from 0 (000) to 7 (111). To convert a binary number to octal, you need to combine the binary digits into groups of 3 digits (triads) in two directions, starting from the decimal separator. If necessary, you need to add insignificant zeros to the left of the original number. If a number contains a fractional part, then to the right of it you can also add insignificant zeros until all triads are filled. Each triad is then replaced by an octal digit.

    Example: Convert the number 1101110.01 2 to octal number system.

    We combine binary digits into triads from right to left. We get

    001 101 110,010 2 = 156,2 8 .

    To convert a number from octal to binary, you need to write each octal digit in binary code:

    156,2 8 = 001 101 110,010 2 .

    The four digits of the hexadecimal number system implement all possible combinations of hexadecimal digits in the binary number system: from 0 (0000) to F(1111). To convert a binary number to hexadecimal, you need to combine the binary digits into groups of 4 digits (tetrads) in two directions, starting from the decimal separator. If necessary, you need to add insignificant zeros to the left of the original number. If the number contains a fractional part, then to the right of it you also need to add insignificant zeros until all notebooks are filled. Each tetrad is then replaced with a hexadecimal digit.

    Example: Convert the number 1101110.11 2 to hexadecimal number system.

    We combine binary digits into tetrads from right to left. We get

    0110 1110.1100 2 = 6E,C 16 .

    To convert a number from hexadecimal to binary, you need to write each hexadecimal digit in binary code.

    Hexadecimal number system(Also - hexadecimal code) is a positional number system with an integer base 16. Sometimes in the literature the term hex (pronounced hex, short for English hexadecimal) is also used. The digits of this number system are usually used in Arabic numerals 0-9, as well as the first characters of the Latin alphabet A-F. The letters correspond to the following decimal values:

    • * A -10;
    • *B—11;
    • *C—12;
    • * D -13;
    • * E - 14;
    • * F - 15.

    Thus, ten Arabic numerals, coupled with six Latin letters, make up the sixteen digits of the system.

    By the way, on our website you can convert any text into decimal, hexadecimal, binary code using the online code calculator.

    Application. Hex code widely used in low-level programming as well as in various computer reference documents. The popularity of the system is justified by the architectural solutions of modern computers: they have a byte (consisting of eight bits) as the minimum unit of information - and the value of a byte is conveniently written using two hexadecimal digits. The byte value can range from #00 to #FF (0 to 255 in decimal notation) - in other words, using hexadecimal code, you can write any state of the byte, while there are no “extra” digits not used in the recording.

    Encoded Unicode Four hexadecimal digits are used to record the character number. The RGB color notation (Red, Green, Blue) also often uses hexadecimal code (for example, #FF0000 is a bright red color notation).

    A method for writing hexadecimal code.

    Mathematical way of writing. In mathematical notation, the base of the system is written in decimal form as a subscript to the right of the number. Decimal notation the numbers 3032 can be written as 3032 10; in hexadecimal, this number will have the notation BD8 16.

    In the syntax of programming languages. Syntax various languages programming sets the format for writing a number using hexadecimal code:

    * The syntax of some varieties of assembly language uses the Latin letter “h”, which is placed to the right of the number, for example: 20Dh. If the number starts with Latin letter, then a zero is placed in front of it, for example: 0A0Bh. This is done in order to distinguish values ​​using constants from constants. hexadecimal code;

    * Other types of assembler, as well as Pascal (and its variants such as Delphi) and some Basic dialects, use the "$" prefix: $A15;

    * In language HTML markup, as well as in cascade CSS files, to specify the color in RGB format with hexadecimal notation, the prefix “#” is used: #00DC00.

    How to convert hexadecimal code to another system?

    Convert from hexadecimal to decimal. To perform a conversion operation from the hexadecimal system to the decimal system, you need to represent the original number as the sum of the products of the digits in the digits of the hexadecimal number and the power of the base.

    Binary SS

    hex SS

    For example, you need to translate the hexadecimal number A14: it has three digits. Using the rule, we write it as a sum of powers with a base of 16:

    A14 16 = 10.16 2 + 1.16 1 + 4.16 0 = 10.256 + 1.16 + 4.1 = 2560 + 16 + 4 = 2580 10

    Converting numbers from binary to hexadecimal and vice versa.

    A notebook table is used for translation. To convert a number from the binary to the decimal system, you need to split it into separate tetrads from right to left, and then, using the table, replace each tetrad with the corresponding hexadecimal digit. Moreover, if the number of digits is not a multiple of four, then it is necessary to add the corresponding number of zeros to the right of the number in order for the total number binary digits became a multiple of four.

    Table of notebooks for translation.

    To convert from hexadecimal to binary, you need to perform the reverse operation: replace each digit with a tetrad from the table.

    Binary SS

    Octal SS

    Example conversion from hexadecimal to binary: A5E 16 = 1010 0101 1110 = 101001011110 2

    Example conversion from binary to hexadecimal: 111100111 2 = 0001 1110 0111 = 1E7 16

    In this example, the number of digits in the original binary number was not four (9), so leading zeros were added for a total of 12 digits.

    Automatic translation. Quick conversion from hexadecimal number system to one of three popular systems(binary, octal and decimal), as well as reverse translation, can be performed using a standard calculator included with Windows OS. Open the calculator, select View -> Programmer from the menu. IN this mode you can set the number system used in at the moment(see menu on the left: Hex, Dec, Oct, Bin). In this case, changing the current number system automatically produces a translation.

    Originated in ancient Babylon. In India, the system works in the form of positional decimal numbering using zero, among Hindus this system numbers were borrowed by the Arab nation, and the Europeans, in turn, took them from them. In Europe, this system began to be called Arabic.

    Positional system dead reckoning— the meaning of all digits depends on the position (digit) of the given digit in the number.

    Examples, the standard decimal number system is a positional system. Let's say given a number453 . Number 4 stands for hundreds and corresponds to a number400, 5 - number of tens and corresponds to the value50 , A 3 - units and meaning3 . It is easy to see that as the digit increases, the value increases. Thus, we write the given number as a sum400+50+3=453.

    Hexadecimal number system.

    Hexadecimal number system(hexadecimal numbers) - positional number system. Hexadecimal base is the number 16.

    By writing numbers in the octal number system we get fairly compact expressions, but in the hexadecimal system we get more compact expressions.

    The first ten digits of the sixteen hexadecimal digits are standard spacing 0 - 9 , the next six digits are expressed using the first letters of the Latin alphabet: A, B, C, D, E, F. Convert from hexadecimal to binary and reverse side do the same process for the octal system.

    Application of the hexadecimal number system.

    The hexadecimal number system is used quite well in modern computers, For example use it to indicate color: #FFFFFF- white color.

    Converting numbers from one number system to another.

    Converting numbers from hexadecimal to decimal.

    To translate hexadecimal number to decimal, you need to reduce the given number to the form of the sum of the products of the powers of the base of the hexadecimal number system by the corresponding digits in the digits of the hexadecimal number.

    For example, convert the hexadecimal number 5A3 to decimal. Here 3 numbers. Based on the above rule, we reduce it to the form of a sum of powers with a base of 16:

    5A3 16 = 3·16 0 +10·16 1 +5·16 2 = 3·1+10·16+5·256 = 3+160+1280 = 1443 10

    Converting numbers from binary to hexadecimal and vice versa.

    To translate polysemantic binary number in the hexadecimal system, you need to divide it into tetrads from right to left and replace all tetrads with the corresponding hexadecimal digit. To convert a number from the hexadecimal system to the binary system, you need to change each digit to the corresponding tetrads from the conversion table, which you will find below.

    For example:

    010110100011 2 = 0101 1010 0011 = 5A3 16

    Number conversion table.

    An algorithm for converting numbers from one number system to another.

    1. From the decimal number system:

    • divide the number by the base of the translated number system;
    • find the remainder when dividing the integer part of a number;
    • write down all remainders from division in reverse order;

    2. From the binary number system:

    • to convert to the decimal number system, we find the sum of the products of base 2 by the corresponding degree of digit;
    • To convert a number to octal, we divide the number into triads.

    For example, 1000110 = 1,000 110 = 1068

    • To convert a number from the binary number system to hexadecimal, we divide the number into groups of 4 digits.

    For example, 1000110 = 100 0110 = 4616.

    Translation tables:

    Binary SS

    Hexadecimal SS

    0000

    0001

    0010

    0011

    0100

    0101

    0110

    0111

    1000

    1001

    1010

    1011

    1100

    1101

    1110

    1111

    Binary SS

    Many computer users understand that a computer operates in a binary number system. Traditionally, the states of a binary system are represented by the numbers 0 and 1, although, more precisely, each state indicates the presence or absence of a signal, i.e. it would be more correct to call the states “off” and “on”, or “no” and “yes”. The state “off” or “no” corresponds to the number 0, and the state “on” or “yes” corresponds to the number 1. For ordinary users Usually there is no need to fully understand the structure of the computer, but the binary number system makes itself felt in the form of various restrictions based on powers of two. A more compact version of the binary system is called hexadecimal. The number sixteen is the fourth power of two. It follows from this that you can quite simply convert long binary sequences of zeros and ones into short hexadecimal ones. To do this, simply break the binary sequence into groups of four digits (digits) starting with the least significant digit (on the right) and replace each group with the corresponding hexadecimal value.

    The hexadecimal system is usually used for the convenience of perceiving binary data, since conversions from the hexadecimal system to the binary system and back are carried out by simply replacing strings. The computer works exclusively with binary sequences, and the hexadecimal notation of this sequence is four times more compact, since this system has base 16 (2 16), and binary 2. The binary sequence can be quite cumbersome. For example, writing the number 513 requires ten binary digits (1000000001), but only three in hexadecimal (201). However, sixteen is required to represent any hexadecimal numbers different characters, and not ten, which are used in our usual decimal system Reckoning. The first ten characters are characters in the range from 0 to 9, the rest are letters of the Latin alphabet in the range from A to F. The letters are usually (but not always) written in uppercase (capital) in hexadecimal notation of the number. The first ten characters (from 0 to 9) are written similarly to numbers in the decimal number system and correspond to them. Letters in the range A through F correspond to values ​​in the range 10 to 15.

    Consider the correspondence of numbers from 0 to 15 hexadecimal and binary systems Reckoning.

    Decimal notation Hexadecimal notation Binary notation
    0 0 0000
    1 1 0001
    2 2 0010
    3 3 0011
    4 4 0100
    5 5 0101
    6 6 0110
    7 7 0111
    8 8 1000
    9 9 1001
    10 A 1010
    11 B 1011
    12 C 1100
    13 D 1101
    14 E 1110
    15 F 1111

    The entries for 10, 11, etc. in decimal, binary, and hexadecimal systems do not correspond to each other. Let's look at a small example. Let us have a hexadecimal number 1A5E. for transfer to binary notation Simply replace the hexadecimal digits with the corresponding binary groups. The result is 0001 1010 0101 1110. If we remove the insignificant zeros in front of the number and write it without separators, we get 1101001011110. For the reverse translation, we divide the number into groups of four digits, starting with the least significant (on the right side), and also for convenience we add insignificant zeros to senior group up to 4 digits. We get 0001 1010 0101 1110. Replace the groups with the corresponding ones hexadecimal values, we get 1A5E.

    To convert a hexadecimal number into a decimal representation, you can use the scheme by which we write decimal numbers. In a decimal number, each digit represents the corresponding power of ten, starting from zero and increasing from right to left. For example, decimal number 123 means 1*10 2 + 2*10 1 + 3*10 0 . Using a similar method, we convert the number 1A5E to the decimal number system. In the hexadecimal number system, as well as in the decimal number system, each digit denotes the corresponding power of the number sixteen, starting from zero and increasing from right to left. The characters 1 and 5 in hexadecimal correspond to the values ​​1 and 5 in decimal, and the characters A and E correspond to 10 and 14. Then 1A5E can be represented in decimal as 1*16 3 + 10*16 2 + 5*16 1 + 14*16 0 = 6750. However, to evaluate hexadecimal numbers it is not at all necessary to convert them to decimal. The rules for comparison, addition and multiplication in this system are the same as in the decimal system, the main thing is not to forget that each digit can contain values ​​from 0 to 15. For more quick translation number between the number system can be used standard calculator in Windows, to do this, just select the number system in the advanced mode of the calculator, enter a number in it and select the right system number in which the result should be displayed.

    Because numeric-only hexadecimal numbers are easily confused with decimal numbers, they are usually marked in a way that makes it clear that hexadecimal notation is used. Hexadecimal entries are usually marked by either adding a lowercase "h" to the end or adding a "0x" prefix before the number. Thus, the hexadecimal number 1A5E can be written as 1A5Eh or 0x1A5E, where a trailing “h” or a leading “0x” indicates that hexadecimal notation is used.