Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Science 210 Computer Organization

Similar presentations


Presentation on theme: "Computer Science 210 Computer Organization"— Presentation transcript:

1 Computer Science 210 Computer Organization
Number Systems Unsigned Integers

2 People Decimal Numbers (base 10) Sign-Magnitude (-324)
Decimal Fractions (23.27) Letters for text

3 Computers Binary Numbers (base 2) Sign-magnitude
Binary fractions and floating point ASCII codes for characters (A65)

4 Why binary? Information is stored in computer via voltage levels.
Using decimal would require 10 distinct and reliable levels for each digit. This is not feasible with reasonable reliability and financial constraints. Everything in computer is stored using bits: numbers, text, programs, pictures, sounds, videos, ...

5 Decimal: Non-negatives
Base 10 Uses decimal digits: 0, 1, . . ., 9 Positional System - position gives power Example: = 3x x x x100 Positions: …543210

6 Binary: Non-negatives
Base 2 Uses binary digits (bits): 0,1 Positional system Example: = 1x23 + 1x22 + 0x21 + 1x20

7 Conversions External Internal (For people) (For computer) A People want to see and enter numbers in decimal. Computers must store and compute with bits.

8 Binary to Decimal Conversion
Algorithm: Expand binary number using positional scheme. Perform computation using decimal arithmetic. Example:  1x24 + 1x23 + 0x22 + 0x21 + 1x = = = 2510

9 Decimal to Binary - Algorithm 1
Algorithm: While N  0 do Set N to N/2 (whole part) Record the remainder (1 or 0) Set A to remainders in reverse order

10 Decimal to binary - Example
Example: Convert to binary N Rem N Rem 32410 =

11 Decimal to Binary - Algorithm 2
Algorithm: Set A to 0 (all bits 0) While N  0 do Find largest P with 2P  N Set bit in position P of A to 1 Set N to N - 2P

12 Decimal to binary - Example
Example: Convert to binary N Power P A 32410 =

13 Octal Numbers Base 8 Digits 0,1,2,3,4,5,6,7
Not so many digits as binary Easy to convert to and from binary Often used by people who need to see the internal representation of data, programs, etc.

14 Octal Conversions Octal to Binary Binary to Octal
Simply convert each octal digit to a three bit binary number. Example: = Binary to Octal Starting at right, group into 3 bit groups Convert each group to an octal digit Example = =

15 Hexadecimal Base 16 Digits 0,…,9,A,B,C,D,E,F Hexadecimal  Binary
Just like Octal, only use 4 bits per digit. Example: 98C316 = Example = = 34EB

16 Binary Addition One bit numbers: + 0 1 0 | 0 1 1 | 1 10
Example (53) (45) (98)

17 Overflow In a given type of computer, the size of integers is a fixed number of bits. 16 or 32 bits are popular choices It is possible that addition of two n bit numbers yields a result requiring n+1 bits. Overflow is the term for an operation whose results exceeds the size allowed for a number.


Download ppt "Computer Science 210 Computer Organization"

Similar presentations


Ads by Google