Chapter 2: Data Representation

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Converting the Hexadecimal Number 123D^16 to Decimal

In expanded notation, this hexadecimal number is: *-(1*4096) + (2*256) + (3*16) + (D*1)* *D* in hexadecimal is *13* in decimal, so: *-4096 + 512 + 48 + 13 = 4669* Therefore, *123D16 = 466910*

2.2 The Hexadecimal System

The hexadecimal system uses a base of *16.* -There is a one's column (16^0) -a *16's* column (16^1) -a *256's* column (16^2) -a *4,096's* column (16^3) -a *65,536's* column (16^4) -Rarely need to deal with anything larger than the *16^4's* column. -The hexadecimal system makes it easier for humans to read binary notation

Converting the Decimal Number 29^10 to Binary

*-29* is less than *32* but greater than *16* so put a 1 in the *16's (2^4)* column. *29 - 16 = 13* *-13* is less than *16* but greater than *8* so put a 1 in the *8's (2^3)* column *13 - 8 = 5* *-5* is less than *8* but greater than *4* so put a 1 in the *4's (2^2)* column *5 - 4 = 1* *-1* is less than *2* so there is nothing in the *2's (2^1)* column -Put a *0* in the *2's* column -You'll have *1* left so put a *1* in the *1's (2^0)* column Therefore, *29^10 = 111012*

Overflow

*Overflow* occurs if you try to store an unsigned integer that is bigger than the maximum unsigned value that can be handled by that computer. To store the decimal integer *23^10* in a 4-bit memory location: -range of integers available in 4-bit location is *0^10* through *15^10* Therefore, attempting to store *23^10* in a 4-bit location gives an *overflow.* To store the decimal integer *65,537^10* in a 16-bit memory location: -range of integers available in 16-bit location is *0^10* through *65535^10* Therefore, attempting to store this number in a 16-bit location gives an *overflow.* *Range of Unsigned Integers:* -8 bits: *ranges* from 0...255 -16 bits: *ranges* from 0...65,535 -32 bits: *ranges* from 0...4,295,967,295 -64 bits: *ranges* from 0...18,446,740,000,000,000,000 (approx.)

Unsigned Integer Format

-A computer processes information in the form of *bytes.* -Bytes are normally 8 to 16 bits. -To store *11^2* and *101101^2* both must have the same length as a byte. -Do this by adding 0s to the left of the number to fill up as many places as needed for a byte. -This is called the *unsigned form of an integer.*

Bases and Exponents

-Any number squared means that number times itself. *Example:* *10* is the base and *2* is the exponent: *-102 = 10*10 = 100* -When a number is raised to a positive integer power, it is multiplied by itself that number of times. Example: the base is *5* and the exponent is *6:* *-56 = 5*5*5*5*5*5 = 15,625* *Exception 1:* When a non-zero number is raised to the power of 0, the result is always *1.* *5,3450* = 1 *40* = 1 *(-31)0* = 1 *Exception 2:* *0^0* = undefined

2.3 Integer Representation

-How computers process numbers depends on each number's *type.* *-Integers* are stored and processed in quite a different manner from *floating point numbers.* -Even within the broad categories of integers and floating point numbers, there are more distinctions. -Integers can be stored as unsigned numbers (all non-negative) or as signed numbers (positive, negative, and zero). -Floating point numbers also have several variations.

Using Hexadecimal Notation

-It is common to write a long binary number in hexadecimal notation. -The 15 hexadecimal digits represent all combinations of a 4-bit binary number. Convert the following binary number to hexadecimal notation: *1110101000001111^2* 1) Separate the binary number into sets of 4 digits: ^1110 1010 0000 1111^ 2) Refer to the table, if necessary, to make the conversions *11102 = E^16* *10102 = A^16* *00002 = 0^16* *11112 = F^16* Therefore, *1110101000001111^2 is EA0F^16*

Binary system

-The binary system follows the same rules as the decimal system. However, the main difference is that the binary system uses a *base of 2* and has only *two digits (0 and 1)* -The rightmost column of the binary system is the one's column *(2^0).* It can contain a *0* or a *1.* -The next number after one is two; in binary, a two is represented by a 1 in the two's column *(2^1)* and a 0 in the one's column *(2^0)* -100 in decimal is represented by a 1 in the one-hundred's (10^2) column and 0s in the ten's column (101) and the one's column (10^0) -In binary, a *1* in the *2^2's* column represents the number *4;* i.e. *100*

Hexadecimal Digits

-The decimal system uses 10 digits (0 through 9) in each column (base 10) -The binary system uses two digits (0 and 1) in each column (base 2) -The hexadecimal system uses 16 digits in each column (base 16) -How can you represent 10 in the one's column in base 16? There is no way to distinguish "ten" (written as 10) from "sixteen" (also written as 10 a one in the 16's column and a zero in the one's column) -Use uppercase letters to represent the digits 10 through 15 *Hexadecimal digits* are 0 through 9 and A through F -10^10 is represented as A^16 -11^10 is represented as B^16 -12^10 is represented as C^16 -13^10 is represented as D^16 -14^10 is represented as E^16 -15^10 is represented as F^16

2.1 Decimal and Binary Representation

-The number system we normally use is the decimal system, which uses 10 as the base. -But a number system can use any base. -Computers work with the *binary* system (base 2). Other systems used with computers are *octal (base 8)* and *hexadecimal (base 16).*

Sign-and-Magnitude Format

-The simple method to convert a decimal integer to binary works well to represent positive integers and zero. We need a way to represent negative integers. -The *sign-and-magnitude format* is one way. -The leftmost bit is reserved to represent the *sign.* -The other bits represent the *magnitude (or the abs. value)* of the integer. To store the decimal integer *+23^10* in an 8-bit memory location using sign-and-magnitude format: -Convert *23^10* to binary: *10111^2* -Since this is an 8-bit memory location, 7 bits are used to store the magnitude of the number. *-10111^2* uses 5 bits so add two *0s* to the left to make up 7 bits: *0010111^2* -Finally, look at the sign. This number is positive so add a *0* in the leftmost place to show the positive sign. Therefore, *+23^10* in sign-and-magnitude format in an 8-bit location is *00010111^2* To Store the decimal integer *-19^10* in a 16-bit memory location using sign-and-magnitude format: -Convert *19^10* to binary: *10011^2* -Since this is a 16-bit memory location, 15 bits are used to store the magnitude of the number. *-10011^2* uses 5 bits so add ten *0s* to the left to make up 15 bits: *000000000010011^2* -Finally, look at the sign. This number is negative so add a *1* in the leftmost place to show the negative sign. -Therefore, *-19^10* in sign-and-magnitude format in an 8-bit location is *1000000000010011^2*

Expanded Notation

-The ten digits that are used in the decimal system are *0, 1, 2, 3, 4, 5, 6, 7, 8, and 9.* -Any number in the decimal system can be written as a sum of each digit multiplied by the value of its column. This is called *expanded notation.* The number *6,825* in the decimal system actually means: 5*100 = 5*1 = 5 + 2*101 = 2*10 = 20 + 8*102 = 8*100 = 800 + 6*103 = 6*1,000 = 6,000 6,825 Therefore, *6,825* can be expressed as: *6*103 + 8*102 + 2*101 + 5*100*

Converting the Decimal Number 172^10 to Binary

There is one *128* in *172* so put a *1* in the *128's (2^7)* column *172 - 128 = 44* *-44* is less than *64* so put a *0* in the *64's (2^6)* column *-44* is less than *64* but greater than *32* so put a *1* in the *32's (2^5)* column *44 - 32 = 12* *-12* is less than *16* but greater than *8* so put a *0* in the *16's (2^4)* column and a *1* in the *8's (2^3)* column *12 - 8 = 4* -Put a *1* in the *4's (2^2)* column *4 - 4 = 0* -Put *0s* in the last two columns

Converting the Decimal Number 23^10 to Hexadecimal

There is one *16* in 23^10 so put a *1* in the *16's* column *23 - 16 = 7* so put a *7* in the *1's* column Therefore, *2310 = 1716* *Converting the Decimal Number 875^10 to Hexadecimal* *-875* is less than *4,096* but greater than *256* so there is nothing in the *4,096's (16^3)* column --Divide *875 by 256* to see how many *256s* there are. *875 ÷ 256 = 3* with a remainder of *107* Put a *3* in the *256's* column *-107 ÷ 16 = 6* with a remainder of *11* Put a *6* in the *16's* column *-11* in decimal notation = *B in hexadecimal notation* -Put a *B* in the *1's* column -Therefore, *87510 = 36B16*

Converting Binary to Decimal

To convert a binary number back to decimal, just add the value of each binary column. *To convert the binary number *1011^2* to decimal* -There is a *1* in the one's column -There is a *1* in the two's column so the value of that column is *2* -There is a *0* in the four's column so the value of that is *0* -There is a *1* in the eight's column so the value of that column is *8* 1 + 2 + 0 + 8 = 11 Therefore, *10112 = 1110* -There is a 0 in the one's column -There is a 1 in the two's column so the value of that column is 2 -There is a 0 in the four's column so the value of that is 0 -There is a 1 in the eight's column so the value of that column is 8 -There is a 0 in the 16's column -There is a 1 in the 32's column so the value of that column is 32 -There is a 0 in the 64's column -There is a 1 in the 128's column so the value of that column is 128 *0 + 2 + 0 + 8 + 0 + 32 + 0 + 128 = 170* Therefore, *101010102 = 17010*

Unsigned Binary Integers

To store the decimal integer *5^10* in an 8-bit memory location: -Convert *5^10* to binary: *101^2* -Add five *0s* to the left to make 8 bits: *-00000101*^2 To store the decimal integer *928^10* in a 16-bit memory location: -Convert *928^10* to binary: *1110100000^2* -Add six *0s* to the left to make 16 bits: *-0000001110100000^2*


संबंधित स्टडी सेट्स

الاردن والقضية الفلسطينية

View Set

SSN chọn đáp áp, SSN301 - TF

View Set

Chapter 6: Microbial Metabolism: Fueling Cell Growth

View Set

Mastering A&P Chapter 5 - Integumentary System

View Set

Chapter Two: Difference Between Private and Government

View Set

conditioning and learning: ch 4 pavlovian textbook readings

View Set