Part 4: Hexadecimal Representation (Base 16) Another commonly used number system in computer science is hexadecimal, which is base 16. That means each digit has 16 possible values and the position of each digit going from right to left represents increasing powers of 16. In order to represent 16 possible values in a single digit, we use letters to represent the numbers greater than 9: A B C D E F 10 11 12 13 14 15 The process for converting a hexadecimal number to decimal is the same as for binary, just using powers of 16. Here is an example converting the number 1B7 to decimal: 1 B 7 256's place 16's place 1's place 16^2 16^1 16^0 (16^2 * 1) + (16^1 * 11) + (16^0 * 7) =          (the letter B represents 11 as shown in the table above) (256 * 1) + (16 * 11) + (1 * 7) =  256 + 176 + 7 = 439 So the number 439 in hexadecimal is 1B7. You can also convert decimal to hexadecimal using the same division method as binary, except by dividing by 16. Remember to convert the remainders over 9 into the corresponding letters.   To differentiate between numbers in different number systems, you will sometimes see the numbers with a radix letter written after them. We use "d" for decimal, "b" for binary, and "h" for hexadecimal. This way we don't get confused about which base system a number is using. Number with radix Number system Value when converted to decimal 100d decimal (base 10) 100 100b binary (base 2) 4 100h hexadecimal (base 16) 256   The reason we use hexadecimal is because it can represent binary numbers in a fraction of the written space. A byte of binary would normally take up 8 digits, but that same number can be written using just 2 hexadecimal digits: 11010100 = D4 Converting between the two is also very easy - each set of 4 binary bits directly corresponds to a single digit of hexadecimal. You can take each set of 4 binary bits, convert them individually, then stick them back together. This also works in reverse. Binary 1101 0100 To decimal 13 4 To Hexadecimal D 4 Exercise 8: What is the hexadecimal number FA in decimal? Exercise 9: What is the hexadecimal number 3B8F in binary? The result will be 16 digits, since each digit in hexadecimal corresponds to 4 digits in binary.   Part 5: Character Sets We've now covered how to represent numbers in computer memory. How do we represent letters and other characters, such as punctuation?  The answer is thankfully very simple. We give a number to each symbol that is possible to type (including capital letters, lowercase letters, punctuation, spaces, underscores, slashes, number digits, math symbols, and more) and store text as those encoded numbers. There are standardized tables called "character sets", which keep track of the codes given to each symbol. One of the most common character sets is called ASCII, which is also covered in the discussion assignment for this week. Other character sets include ANSI and Unicode. In this class we will exclusively use ASCII. One advantage of ASCII is that every character can be represented using just a single byte. An ASCII table has been provided in this module for your reference, and you can find one easily at any time by Googling "ascii table". Use the ASCII table to answer the following exercises. Exercise 10: How is the letter "d" represented in binary? (Hint: find "d" on the ASCII table and look at its decimal or hexadecimal code, then convert that to binary. Note that uppercase D and lowercase d have different codes!). Exercise 11: Convert the following binary to text by using the process from the previous exercise in reverse. Each set of 8 bits represents a single character. Remember that capitalization matters!                       01001110  01101001  01100011  01100101

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter7: Arrays
Section: Chapter Questions
Problem 9PP: (Data processing) Your professor has asked you to write a C++ program that determines grades at the...
icon
Related questions
Question

Part 4: Hexadecimal Representation (Base 16)

Another commonly used number system in computer science is hexadecimal, which is base 16. That means each digit has 16 possible values and the position of each digit going from right to left represents increasing powers of 16. In order to represent 16 possible values in a single digit, we use letters to represent the numbers greater than 9:

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

The process for converting a hexadecimal number to decimal is the same as for binary, just using powers of 16. Here is an example converting the number 1B7 to decimal:

1 B 7
256's place 16's place 1's place
16^2 16^1 16^0

(16^2 * 1) + (16^1 * 11) + (16^0 * 7) =          (the letter B represents 11 as shown in the table above)

(256 * 1) + (16 * 11) + (1 * 7) = 

256 + 176 + 7 =

439

So the number 439 in hexadecimal is 1B7.

You can also convert decimal to hexadecimal using the same division method as binary, except by dividing by 16. Remember to convert the remainders over 9 into the corresponding letters.

 

To differentiate between numbers in different number systems, you will sometimes see the numbers with a radix letter written after them. We use "d" for decimal, "b" for binary, and "h" for hexadecimal. This way we don't get confused about which base system a number is using.

Number with radix Number system Value when converted to decimal
100d decimal (base 10) 100
100b binary (base 2) 4
100h hexadecimal (base 16) 256

 

The reason we use hexadecimal is because it can represent binary numbers in a fraction of the written space. A byte of binary would normally take up 8 digits, but that same number can be written using just 2 hexadecimal digits:

11010100 = D4

Converting between the two is also very easy - each set of 4 binary bits directly corresponds to a single digit of hexadecimal. You can take each set of 4 binary bits, convert them individually, then stick them back together. This also works in reverse.

Binary 1101 0100
To decimal 13 4
To Hexadecimal D 4

Exercise 8: What is the hexadecimal number FA in decimal?

Exercise 9: What is the hexadecimal number 3B8F in binary? The result will be 16 digits, since each digit in hexadecimal corresponds to 4 digits in binary.

 

Part 5: Character Sets

We've now covered how to represent numbers in computer memory. How do we represent letters and other characters, such as punctuation? 

The answer is thankfully very simple. We give a number to each symbol that is possible to type (including capital letters, lowercase letters, punctuation, spaces, underscores, slashes, number digits, math symbols, and more) and store text as those encoded numbers. There are standardized tables called "character sets", which keep track of the codes given to each symbol. One of the most common character sets is called ASCII, which is also covered in the discussion assignment for this week. Other character sets include ANSI and Unicode.

In this class we will exclusively use ASCII. One advantage of ASCII is that every character can be represented using just a single byte. An ASCII table has been provided in this module for your reference, and you can find one easily at any time by Googling "ascii table". Use the ASCII table to answer the following exercises.

Exercise 10: How is the letter "d" represented in binary? (Hint: find "d" on the ASCII table and look at its decimal or hexadecimal code, then convert that to binary. Note that uppercase D and lowercase d have different codes!).

Exercise 11: Convert the following binary to text by using the process from the previous exercise in reverse. Each set of 8 bits represents a single character. Remember that capitalization matters!

                      01001110  01101001  01100011  01100101

 

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps

Blurred answer
Knowledge Booster
Mathematical functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning