Computer Science
Hexadecimal Conversion
Hexadecimal conversion is the process of converting numbers from base 10 (decimal) to base 16 (hexadecimal) or vice versa. In computer science, hexadecimal is commonly used to represent binary data in a more human-readable format. Each hexadecimal digit represents four binary digits, making it a convenient way to work with binary data in programming and digital electronics.
Written by Perlego with AI-assistance
Related key terms
1 of 5
8 Key excerpts on "Hexadecimal Conversion"
- eBook - PDF
- Parag K. Lala(Author)
- 2007(Publication Date)
- Wiley-Interscience(Publisher)
Table 1.2 shows the relationship between decimal, binary, octal, and hexade-cimal number systems. The conversion of a binary number to a hexadecimal number con-sists of partitioning the binary numbers into groups of 4 bits, and representing each group with its hexadecimal equivalent. 1.5 HEXADECIMAL NUMBERS 11 Example 1.17 The binary number 1010011011110001 is grouped as 1010 0110 1111 0001 which is shown here in hexadecimal: A6F1 H The conversion from hexadecimal to binary is straightforward. Each hexadecimal digit is replaced by the corresponding 4-bit equivalent from Table 1.2. For example, the binary equivalent of 4AC2 H is 4 A C 2 0100 1010 1110 0010 Thus 4AC2 H = 0100101011100010 2 . Sometimes it is necessary to convert a hexadecimal number to decimal. Each position in a hexadecimal number is 16 times more signi fi cant than the previous position. Thus the decimal equivalent for 1A2D H is 1 16 3 A 16 2 2 16 1 D 16 0 1 16 3 10 16 2 2 16 1 13 16 0 6701 Hexadecimal numbers are often used in describing the data in a computer memory. A com-puter memory stores a large number of words, each of which is a standard size collection TABLE 1.2 Number Equivalents Decimal Binary Octal Hexadecimal 0 0000 0 0 1 0001 1 1 2 0010 2 2 3 0011 3 3 4 0100 4 4 5 0101 5 5 6 0110 6 6 7 0111 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 12 NUMBER SYSTEMS AND BINARY CODES of bits. An 8-bit word is known as a byte . A hexadecimal digit may be considered as half of a byte. Two hexadecimal digits constitute one byte, the rightmost 4 bits corresponding to half a byte, and the leftmost 4 bits corresponding to the other half of the byte. Often a half-byte is called a nibble . Hexadecimal addition and subtraction are performed as for any other positional number system. Example 1.18 Let us fi nd the sum of 688 H and 679 H . - eBook - PDF
Digital Electronic Circuits
Principles and Practices
- Shuqin Lou, Chunling Yang(Authors)
- 2019(Publication Date)
- De Gruyter(Publisher)
2.3.2 Conversion between binary and hexadecimal 1. Conversion from binary system into hexadecimal system A four-bit binary number can represent 16 different decimal values from 0 to 15. A one-bit hexadecimal number also has 16 different digits (0 – 9 and A – F), correspond-ing to 16 different decimal values too. Thus, a one-bit hexadecimal number can be represented by a four-bit binary number. The conversion from binary to hexadecimal typically begins with grouping the bits into sets of four starting at the radix point (starting at the LSB for integer part, while the MSB for the fractional part), adding zeros as needed to fill out the groups. Then, assign to each group with the equivalent hexadecimal digit. Example 2.3 Convert a binary number (10110100111100.01001) 2 into its corresponding hexadecimal number. Solution 0010 ð 1101 0011 1100 : 0100 1000 Þ 2 # # # # # # 2 D 3 C : 4 8 Thus, (10110100111100.01001) 2 = (2D3C.48) 16 . 2.3 Conversion between number systems 25 2. Conversion from hexadecimal system into binary system Every bit of a hexadecimal number can be represented by a four-bit binary number. Hence, the conversion from a hexadecimal number into its equivalent binary number is typically realized by converting bit-by-bit the hexadecimal number using the reverse process shown in Example 2.3. Example 2.4 Convert a hexadecimal number (4FB.CA) 16 into its corresponding binary number. Solution 4 ð F B : C A Þ 16 # # # # # 0100 1111 1011 : 1100 1010 Thus, 4FB.CA ð Þ 16 = 010011111011.11001010 ð Þ 2 . 2.3.3 Conversion between binary and octal The conversion between a binary and octal system is similar to the conversion between binary and hexadecimal system. - eBook - PDF
- Malcolm Bull(Author)
- 2016(Publication Date)
- Newnes(Publisher)
It is more convenient to use hexadecimal notation to write down these patterns. To use hexadecimal notation to represent a value such as: 01011011 the binary string is split into two quartets of four binary digits: 0101 and 1011 and these two quartets are written as hexadecimal digits according to the table shown in Figure 3.4. Decimal 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Bi nary 0000 0001 0010 001 1 0100 0101 01 10 01 1 1 1000 1001 1010 1011 1100 1 101 1 1 10 1111 Hexadecimal 0 1 2 3 4 5 6 7 8 9 A B C D E F Figure 3.4 Table of hexadecimal digits From the table, we see that: 0101 in binary is equivalent to 5 in hexadecimal 1011 in binary is equivalent to B in hexadecimal so, the binary number: 0101 1011 would be written as: Students' Guide to Programming Languages 5B in hexadecimal notation, and the binary number 01011011 is equivalent to the hexadecimal number 5B. Questions 18 It is important for you to realize that decimal numbers, binary numbers and hexadecimal numbers (and others, such as octal numbers) are only a means of recording a numeric value. Look at the boxes in Figure 3.5. Figure 3.5 How many boxes? Write down the number of boxes as: (a) a decimal number, (b) a binary number (c) a hexadecimal number. These are three different ways of recording the same informa-tion. 19 Write down the hexadecimal equivalents of the following binary numbers: (a) 00001011 (b) 00000100 (c) 01110011 (d) 01111111 102 Data and data types (e) 11001011 (f) 11011001 (g) 11110000 (h) 11110010 (i) 11110100 (j) 11111111 Binary / decimal / hexadecimal Binary, decimal and hexadecimal are simply ways of writing down numeric values, such as the number of boxes in Figure 3.5. They are all equally valid ways of representing information. It's just that one may be more convenient than others at certain times. Decimal notation is really just one way of recording numbers that increases in powers of 10 as you move from right to left across the number. - eBook - PDF
- Aharon Yadin(Author)
- 2016(Publication Date)
- Chapman and Hall/CRC(Publisher)
For base 4, since 4 equals 2 2 , then the group consists of 2 bits. For hexadecimal numbers, since 16 equals 2 4 then the group consists of 4 bits. Data Representation ◾ 55 For example, 10110111 10 11 01 11 2313 2 4 = = or 10110111 1011 0111 7 2 16 = = B • Converting numbers from a system that is a power of 2 to binary numbers. Each digit is broken into its binary equivalence, and the number of bits in the group is deter-mined by the rule described in the opposite conversion. For example, the octal number 765 is converted to a binary number one digit at a time, and each digit represents 3 bits: 765 111 110 101 8 2 = or 1A2F 16 2 0001 1010 0010 1111 = • Converting decimal numbers into numbers in a different base. This type of conver-sion is performed in an iterative way. Each iteration consists of three stages: • Divide the number by the new base • Collect the remainder and replace the original number by the result (integer) • If the result is not zero, go back to the first stage For example, let us assume one has to convert the decimal number 37 into a binary number. 37/2 = 18 Remainder = 1 18/2 = 9 Remainder = 0 9/2 = 4 Remainder = 1 4/2 = 2 Remainder = 0 2/2 = 1 Remainder = 0 1/2 = 0 Remainder = 0 Since the result is zero, the conversion ends. The result is the list of the remainder, where the first remainder is the rightmost digit. The conversion result in this case is 37 100101 10 2 = 56 ◾ Computer Systems Architecture This of course can be easily checked by performing the opposite conversion. 100101 1 2 0 2 1 2 0 2 0 2 1 2 1 4 32 37 2 0 1 2 3 4 5 10 = * + * + * + * + * + * = + + = The method described is relevant for converting any decimal number to any other base. The only difference is that when converting to another based the base is the divisor. - eBook - PDF
The Architecture of Computer Hardware, Systems Software, and Networking
An Information Technology Approach
- Irv Englander, Wilson Wong(Authors)
- 2021(Publication Date)
- Wiley(Publisher)
It may be necessary to mentally add 0s to the left end of the number to convert the most significant digit. This is most easily illustrated with an example: EXAMPLE Convert 13754 8 to base 10: 1 8 8 3 11 8 88 7 95 8 760 5 765 8 6120 4 6124 10 68 NUMBER SYSTEMS EXAMPLE Let us convert 11010111011000 2 to hexadecimal. Grouping the binary number by fours from the right, we have 0011 0101 1101 1000 2 or 35D8 16 Note that we added two zeros at the left end of the binary number to create groups of four. The conversion in the other direction works identically. Thus, 275331 8 becomes 010 111 101 011 011 001 2 For practice, now convert this value to hexadecimal. You should get 17AD9 16 as an answer. Most computer manufacturers today prefer to use hexadecimal, since a 16-bit or 32-bit number can be represented exactly by a four- or eight-digit hexadecimal number. (How many octal digits would be required?) A few manufacturers still use octal representation for some applications. You might ask why it is necessary to represent data in binary form at all. After all, the binary form is used within the computer, where it is usually invisible to the user. There are many occasions, however, where the ability to read the binary data is very useful. Remember that the computer stores both instructions and data in binary form. When debugging a program, it may be desirable to be able to read the program’s instructions and to determine intermediate data steps that the computer is using. Older computers used to provide binary dumps for this purpose. Binary dumps were complete octal listings of everything stored in memory at the time the dump was requested. Even today it is sometimes important, for example, to be able to read the binary data from a disk to recover a lost or damaged file. Modern computer operating systems and networks present a variety of troubleshooting data in hexadecimal form. Conversions between binary and hexadecimal notation are used frequently. - eBook - PDF
- Kyla McMullen, Elizabeth Matthews, June Jamrich Parsons, , Kyla McMullen, Kyla McMullen, Elizabeth Matthews, June Jamrich Parsons(Authors)
- 2021(Publication Date)
- Cengage Learning EMEA(Publisher)
In hex, only one digit. Hexadecimal provides higher information density than binary or decimal, so it is more efficient—at least for humans. Because hex notation is efficient and relatively easy to read, it is used not only for designating colors, but also for memory readouts, raw file readouts, IPv6 Internet addresses, and storage addresses in computer memory. Hollywood uses hex, too. You’ve seen all the garble that appears on hacker screens in movies. That Holly- wood illusion is created by displaying the contents of a file with binary bits converted to hex. In Figure 26-22, each two-digit pair is a hex value. Figure 26-22 A raw file readout displays hex values for the binary data in a document or program 26-4 ASCII AND UNICODE ASCII (26.4.1, 26.4.2, 26.4.3, 26.4.4) Computers work with text as well as numbers, so there has to be an encoding system for representing text with 0 and 1 bits. ASCII is the American Standard Code for Information Interchange. ASCII uses 7 bits to represent text. For example, the ASCII representation of an uppercase A is 1000001. When you type the letter “A” in a word processing document, the computer stores it as 1000001. Copyright 2022 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. - eBook - PDF
- R. Townsend(Author)
- 2014(Publication Date)
- Butterworth-Heinemann(Publisher)
These groups are then written in their code equivalents, which are easily memorised. Two examples will illustrate this, for the same string of bits. Commas are used to separate the groups of bits in each case. Both methods are common, but the hexadecimal representation seems to have gained in popularity, because words of binary numbered length such as 8, 16 or 32 are more conveniently cut up into groups of 4 bits. Octal: The octal equivalent of 1,010,011,111,100,001, is 123741 and of 1, 111, 101,001, 111, 100,is 175174. Number Representation in Computers 89 Hexadecimal: The same strings of bits are now shown in hexadecimal representation. The hexadecimal equivalent of 1010,0111, 1110,0001 is A7E1 and of 1111,1010,0111,1100 isFA7C. Problems 1. Convert the following binary numbers to decimal numbers: (a) 1101, (b) 101 l,(c) 00010101, and (d) 11001101. 2. Convert the same numbers to their decimal equivalents, assuming they are in binary coded decimal. 3. Convert the following integers to binary numbers: (a) 29, (b) 67, (c) 721, (d) 437, (e) 233. 4. Convert the following fractions to binary fractions of 8 significant bits: (a) f, (b)f , (c) 0.625, (d) 0.03725. 5. Convert the numbers in (3) to ternary integers and write the polynomials for these. 6. Write the polynomial representation for the non-uniform number systems of: (a) time in the range of milliseconds to 10 days in terms of milliseconds as the unit, and also of seconds as the unit. (b) Length in yards, feet and inches from ^ of an inch to 10 yards in terms of γ-6 inch as a unit or one inch as a unit. 7. The following sums should be done using complementary numbers in: (a) Nine's complement notation; (b) Ten's complement notation. (i) +721 (ii) +437 (iii) -721 (ix) -437 +437 +233 -233 -721 (v) -437 (vi) +721 (vü) -233 (viii) +437 + 233 -437 +437 -721 8. - eBook - ePub
Numbers
Arithmetic and Computation
- Asok Kumar Mallik, Amit Kumar Das(Authors)
- 2022(Publication Date)
- CRC Press(Publisher)
binary for all sorts of electronic devices including computers. So, simplicity, cost and space reduction can easily be achieved.The reader now, we hope, gets the idea why the binary number system is a universal choice for computers. This transition from 10 different digits (or symbols) to 2 digits reduces the circuit complexity and a perfect natural mapping with the two logic states (FALSE and TRUE). Thus, the use of the binary number system becomes universal in any computer; supercomputers, to hand held devices like your mobile phone.Octal and hexadecimal representations
Binary bit strings are often 16 bit or 32 bit (or even 64 bit) long. It is error prone and time consuming to write them in the binary form by humans. Octal (base = 8; and the digits 0, 1,…, 7) or hexadecimal (base=16 and the digits 0, 1, …, 9, A, B, C, …, F) representations help reduce these long bit strings and make them man- ageable. For example, a 16-bit binary number 10| 110| 011| 010| 010| 101| 110 (vertical lines are placed after every 3rd bit starting from the rightmost position for a better readability and easier conversion) can be written in octal as 26322568 . The same binary number 1011| 0011| 0100| 1010| 1110 in hexadecimal is B34E16 . See Appendix F for a table showing decimal number 0 to 15 and their equivalent binary, octal and hexadecimal (Hex) representations.We may discuss next how a computer using numbers in binary form can carry out the basic arithmetic operations; at least addition. Dropping all other issues we focus on the core part of the computer that carries out addition.6.2 A computer as a black box
Confronted with the challenge of building at least the core arithmetic part of the computer let us make a modest beginning. Consider a computer as a black box (see Fig. 6.3)
Index pages curate the most relevant extracts from our library of academic textbooks. They’ve been created using an in-house natural language model (NLM), each adding context and meaning to key research topics.







