MELJUN CORTES - Number System
Upcoming SlideShare
Loading in...5
×
 

MELJUN CORTES - Number System

on

  • 206 views

MELJUN CORTES - Number System

MELJUN CORTES - Number System

Statistics

Views

Total Views
206
Slideshare-icon Views on SlideShare
206
Embed Views
0

Actions

Likes
0
Downloads
2
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    MELJUN CORTES - Number System MELJUN CORTES - Number System Document Transcript

    • Year 1 LESSON 2 COMPUTER-BASED CALCULATIONS♦ Computers store numbers in binary♦ They calculate in binary♦ Principles of binary calculation are essentially similar to those for decimal♦ When using computers, make sure you know what the binary data means! CS113/0401/v1 Lesson 2 - 1
    • Year 1 BINARY ADDITION 0 + 0 = 0 carry 0 0 + 1 = 1 carry 0 1 + 1 = 0 carry 1 1 + 1 + 1 = 1 carry 1 1010102 + 1110012 11000112 Result = 11000112 111 carry1 + 1 + 1 + 1 = 0 carry 10 (binary) 1101102 + 1011012 + 11110102 CS113/0401/v1 Lesson 2 - 2 11011101
    • Year 1 BINARY SUBTRACTION 1 1 10 1 10 1 0 12 - 1 10 1 1 0 1 1 0 02 0 1 1 0 1 0 0 12♦ Result 11010012♦ This is not the way computers do it CS113/0401/v1 Lesson 2 - 3
    • Year 1 SHIFT OPERATIONS♦ In reality, multiplication and division are done using Shifting♦ Circular, Logical and Arithmetic shifts exit♦ We will consider the Arithmetic Shift CS113/0401/v1 Lesson 2 - 4
    • Year 1 SHIFTING FOR MULTIPLICATION (1)♦ Shift LEFT♦ 73510 shifted left 1 place 7 3 5 7 3 5 0 = 735010 = 73510 X 1010♦ 11012 shifted left 1 place 1 1 0 1 1 1 0 1 0 = 110102 = 11012 X 102 CS113/0401/v1 Lesson 2 - 5
    • Year 1 SHIFTING FOR MULTIPLICATION (2)♦ Binary shift left n places multiples by 2n♦ Fill in right hand side with zeros♦ Beware the sign bit!♦ Repeated doubling cannot change a number’s sign, but it can send it out of range♦ Computers have a special register to detect this CS113/0401/v1 Lesson 2 - 6
    • Year 1SHIFTING FOR DIVISIONCS113/0401/v1 Lesson 2 - 7
    • Year 1NUMBER STORAGE IN THE COMPUTER♦ Computer store is arranged in words♦ Words are fixed length groups of binary digits (bits)♦ Words vary in length on different types of computer♦ Common word lengths are 8, 12, 16, 24 and 32 bits♦ We shall use 12 bit words in examples♦ NB : An 8-bit word is called a byte CS113/0401/v1 Lesson 2 - 8
    • Year 1 SIZE LIMITS ON DATA♦ Computer stores are of finite size♦ This limits the range of values which can be stored and the accuracy of fractions♦ Example • 16-bit words are common and can hold integers in the range from -32768 to +32767 CS113/0401/v1 Lesson 2 - 9
    • Year 1STOREGE OF INTEGERS (1)♦ 735 DECIMAL = 1011011111 (10 bits)♦ Add 2 bits “padding” in a 12-bit word 0 0 1 0 1 1 0 1 1 1 1 1♦ By convention, the first (left-hand) bit is the SIGN BIT♦ Therefore only 11 bits are left for the number value 0 0 1 0 1 1 0 1 1 1 1 1 CS113/0401/v1 Lesson 2 - 10♦ For sign Modulus method : 0 Positive
    • Year 1STOREGE OF INTEGERS (2) Sign bit♦ Small numbers stored in 12-bit 0 words contain mostly “padding” 0 bits 0 0 0 Padding 0 0 0 1 Decimal 9 0♦ Padding is not really wasteful, it is 0 necessary to make the 1 calculation method work properly CS113/0401/v1 Lesson 2 - 11
    • Year 1STOREGE OF INTEGERS (3)♦ The upper limit for storing a number in a 12-bit word is 011111111111 = 2047 decimal♦ Larger numbers need double length CS113/0401/v1 Lesson 2 - 12
    • Year 1STORAGE OF FRACTIONS (1)♦ First bit still sign bit♦ Decimal point not stored • Implied after sign bit CS113/0401/v1 Lesson 2 - 13
    • Year 1STORAGE OF FRACTIONS (2)♦ if 11 bits is not enough for exact representation • Truncate • Round off • Extend to double length (or more) CS113/0401/v1 Lesson 2 - 14
    • Year 1STORAGE OF FRACTIONS (3)♦ Double length fraction 0.7323 decimal♦ Double length fractions have increased accuracy, not range CS113/0401/v1 Lesson 2 - 15
    • Year 1 STORAGE OF MIXEDNUMBERS (FIXED POINT NOTATION)♦ Usual convention is one word for integral part, the other for fraction CS113/0401/v1 Lesson 2 - 16
    • Year 1 TYPES OF NUMBERS♦ Even if you know that the data is numeric, make sure you have the right format CS113/0401/v1 Lesson 2 - 17
    • Year 1STORAGE OF NEGATIVE VALUES (1)♦ Sign-and-modulus method is unsuitable for calculation♦ Computers usually use two’s complement method♦ Three stages to finding a two’s complement Example : -837 decimal CS113/0401/v1 Lesson 2 - 18
    • Year 1STORAGE OF NEGATIVE VALUES (2)♦ Conversion from two’s complement to decimal CS113/0401/v1 Lesson 2 - 19
    • Year 1STORAGE OF NEGATIVE VALUES (3)♦ Ranges of numbers♦ Largest negative number in 12 bits = 100000000000 = -2048♦ Total range of 12 bits is -2048 to + 2047♦ Multiple length works with negative values as well CS113/0401/v1 Lesson 2 - 20
    • Year 1TWO’S COMPLEMENT SUBTRACTIONCS113/0401/v1 Lesson 2 - 21