NumberRepresentation-2

NumberRepresentation-2 - Kingdom Of Saudi Arabia Al-Imam...

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon
Number Representation Chapter 3 in “Foundation of Computer System” Kingdom Of Saudi Arabia Al-Imam Muhammad Ibn Saud Islamic University College of Computer and Information Sciences Information System Department 1 st semester, 2010 – 2011 CS 224: Computer Organization 1 T. Hala A. Al-Rumaih
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Integer Representation Integers are numbers without fraction. 134, -134 are integers . 134.23, -134,567 are not integers . An integer can be positive or negative , negative integer ranges from negative infinity to 0; a positive integer range from 0 to positive infinity. However, no computer can store all integers in this range. To do so would require an infinite number of bits, which means a computer with infinite storage capability. 2
Background image of page 2
Integer Representation (Cont.) To use computer memory more efficiently, two broad categories of integer representation have been developed: unsigned integer and signed integer. Signed integer may also be represented in three distinct ways. 3
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Unsigned integer format Unsigned integer is an integer without a sign. An unsigned integers between 0 and the maximum unsigned integer . Since no computer can represent all integers from 0 to positive infinity. The maximum unsigned integer depend on the number of bits the computer allocates to store an unsigned integer. Range = 0 → (2 N -1) Where N is the number of bits allocated to represent one unsigned integer. 4 # of Bits Range in decimal Range in binary 8 0 255 00000000 11111111 16 0 65,535 0000000000000000 1111111111111111
Background image of page 4
Representation 1. Check if the number in the range. 2. Change the number to binary 3. If the number of bits is less than N, Add 0’s to the left of binary number so that there are a total of N bits. Ex: Store 7 in an 8 -bit memory location. Solution: 1. 7 is in the range of 8-bit memory location (0 255) 2. Change the number to binary = 111. 3. Add five 0s to make a total of N (8) bit = 00000111. 5
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Representation (Cont.) Ex: Store 258 in a 16 -bit memory location. Solution: 1. 258 is in the range of 16-bit memory location (0 65535) 2. Change the number to binary = 100000010. 3. Add seven 0s to make a total of N (16) bits = 0000000100000010. 6
Background image of page 6
Representation (Cont.) Overflow if the number > maximum unsigned integer 7 Decimal 8-bit allocation 16-bit allocation 7 00000111 0000000000000111 234 11101010 0000000011101010 258 overflow 0000000100000010 24760 overflow 0110000010111000 1245678 overflow overflow
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Interpretation Change the N bits from the binary to decimal. EX : Interpret 00101011 in decimal if the number was stored as an unsigned integer. Solution: 00101011= 1× 2 7 +0 × 2 6 +1× 2 5 +0 × 2 4 + 1× 2 3 + 0 × 2 2 +1 × 2 1 +1 × 2 0 = 43 The number in decimal is 43 8
Background image of page 8
Unsigned integer representation can improve the efficiency of storage : You don’t need to store the sign of the integer the entire bit allocation can be used for storing the number.
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 35

NumberRepresentation-2 - Kingdom Of Saudi Arabia Al-Imam...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online