تمثيل البيانات داخل الحاسب II Day 3

Slides:



Advertisements
Similar presentations
قوالب بناء الحاسب II Day 6
Advertisements

Forging new generations of engineers. Binary Addition & Subtraction.
Number Systems Discussion D4.1 Appendix C. Number Systems Counting in Binary Positional Notation Hexadecimal Numbers Negative Numbers.
Chapter 2 : Number System
أنظمة العد الدرس الثاني.
CS 151 Digital Systems Design Lecture 3 More Number Systems.
Representations Example: Numbers –145 –CVL – –91 –
Negative Numbers Module M3.3 Section 2.4. Negative Numbers Subtract by adding ’s complement Ignore carry.
Number Representation (1) Fall 2005 Lecture 12: Number Representation Integers and Computer Arithmetic.
DIGITAL SYSTEMS TCE1111 Representation and Arithmetic Operations with Signed Numbers Week 6 and 7 (Lecture 1 of 2)
ENGIN112 L3: More Number Systems September 8, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 3 More Number Systems.
CSE20 Lecture 3 Number Systems: Negative Numbers 1.Sign and Magnitude Representation 2.1’s Complement Representation 3.2’s Complement Representation 1.
Number Systems and Codes Discussion D4.1. Number Systems Counting in Binary Positional Notation Hexadecimal Numbers Negative Numbers.
Introduction to Number Systems
1 Lecture 2: Number Systems Binary numbers Base conversion Arithmetic Number systems  Sign and magnitude  Ones-complement  Twos-complement Binary-coded.
Chapter 3 Data Representation part2 Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2010.
Binary Representation - Shortcuts n Negation x + x = 1111…1111 two = -1 (in 2’s complement) Therefore, -x = x + 1 n Sign Extension o Positive numbers :
Computer Systems 1 Fundamentals of Computing Negative Binary.
Simple Data Type Representation and conversion of numbers
ES 244: Digital Logic Design Chapter 1 Chapter 1: Introduction Uchechukwu Ofoegbu Temple University.
1 Arithmetic and Logical Operations - Part II. Unsigned Numbers Addition in unsigned numbers is the same regardless of the base. Given a pair of bit sequences.
#1 Lec # 2 Winter EECC341 - Shaaban Positional Number Systems A number system consists of an order set of symbols (digits) with relations.
Computer Architecture
CSE 111 Representing Numeric Data in a Computer Slides adapted from Dr. Kris Schindler.
Chapter 2 Number Systems + Codes. Overview Objective: To use positional number systems To convert decimals to binary integers To convert binary integers.
Complement Numbers. Outline  Negative Numbers Representation  Sign-and-magnitude  1s Complement  2s Complement  Comparison of Sign-and-Magnitude.
Calculating Two’s Complement. The two's complement of a binary number is defined as the value obtained by subtracting the number from a large power of.
1 Digital Design: Number Systems Credits : Slides adapted from: J.F. Wakerly, Digital Design, 4/e, Prentice Hall, 2006 C.H. Roth, Fundamentals of Logic.
Engineering 1040: Mechanisms & Electric Circuits Spring 2014 Number Systems.
Computer Number Systems. d n-1 d n-2 d n d 2-m d 1-m d -m Conventional Radix Number r is the radixd i is a digit d i Є {0, 1, ….., r – 1 } -m ≤
ECE 301 – Digital Electronics Unsigned and Signed Numbers, Binary Arithmetic of Signed Numbers, and Binary Codes (Lecture #2)
Summer 2012ETE Digital Electronics1 Binary Arithmetic of Signed Binary Numbers.
Positional Number Systems
ECE2030 Introduction to Computer Engineering Lecture 2: Number System Prof. Hsien-Hsin Sean Lee School of Electrical and Computer Engineering Georgia Tech.
Lecture 2 Binary Values and Number Systems. The number 943 is an example of a number written in positional notation. The relative positions of the digits.
Number Systems Binary to Decimal Octal to Decimal Hexadecimal to Decimal Binary to Octal Binary to Hexadecimal Two’s Complement.
Number Systems and Logic Prepared by Dr P Marais (Modified by D Burford)
ECE 331 – Digital System Design Representation and Binary Arithmetic of Negative Numbers and Binary Codes (Lecture #10) The slides included herein were.
07/12/ Data Representation Two’s Complement & Binary Arithmetic.
Two’s Complement. A system used to represent a negative number in binary A system used to represent a negative number in binary Positive numbers start.
Addition and Substraction
SAK Chapter 21 Chapter 2 : Number System 2.1 Decimal, Binary, Octal and Hexadecimal Numbers 2.2 Relation between binary number system with other.
CEC 220 Digital Circuit Design Binary Arithmetic & Negative Numbers Monday, January 13 CEC 220 Digital Circuit Design Slide 1 of 14.
CEC 220 Digital Circuit Design Binary Arithmetic & Negative Numbers Fri, Aug 28 CEC 220 Digital Circuit Design Slide 1 of 14.
IT1004: Data Representation and Organization Negative number representation.
In decimal we are quite familiar with placing a “-” sign in front of a number to denote that it is negative The same is true for binary numbers a computer.
Numerical formats What’s the main idea? Want to represent numbers (eg: 45, -12, ) using only bits. We’ve already seen (or you can read in the book)
1. Number Systems. Common Number Systems SystemBaseSymbols Used by humans? Used in computers? Decimal100, 1, … 9YesNo Binary20, 1NoYes Octal80, 1, … 7No.
09/03/20161 Information Representation Two’s Complement & Binary Arithmetic.
بسم الله الرحمن الرحيم تمثيل البيانات داخل الحاسب I Day 2.
1  For recitations  Amr Mahmoud  Office Hours: Monday Benedum Hall.
COSC2410: LAB 2 BINARY ARITHMETIC SIGNED NUMBERS FLOATING POINT REPRESENTATION BOOLEAN ALGEBRA 1.
Negative Number Sign-Magnitude: left-most bit as the sign bit –16 bits –Example: 4-bit numbers is given by is given by ’s complement:
CS2100 Computer Organisation
Numbering Systems.
CHAPTER 9 COMPUTER ARITHMETIC - ALU
Negative Binary Numbers
CSE 102 Introduction to Computer Engineering
Location in course textbook
Addition and Substraction
CS1010 Programming Methodology
Binary Addition & Subtraction
TAO1221 COMPUTER ARCHITECTURE AND ORGANIZATION LAB 6
10 0× 1 = 4× 4 = (وحدات)4 10 1× = 5 50 = (عشرات)5
Data Representation in Computer Systems
Unit 18: Computational Thinking
Decimal and binary representation systems
Binary Addition (1 of 2) Two 1-bit values A B A + B 1
ECE 331 – Digital System Design
1. Number Systems Chapt. 2.
Presentation transcript:

تمثيل البيانات داخل الحاسب II Day 3 بسم الله الرحمن الرحيم تمثيل البيانات داخل الحاسب II Day 3

IIتمثيل البيانات داخل الحاسب المحاضرة الثالثه IIتمثيل البيانات داخل الحاسب

الأهداف لليوم المحاضرة الثالثه 1. مراجعه للمحاضره السابقه. 2. التحويل بين الأنظمه العدديه ماعدا العشري. 3. تمثيل الارقام السالبه. 4. العمليات الحسابيه بالنظام الثنائي. 5. كيفية تمثيل الارقام الكسريه. 6. الخلاصه.

المحاضرة السابقه

الأنظمة العدديه النظام العشري Decimal System النظام الثنائى Binary System النظام السداسي عشر Hexadecimal System النظام الثماني Octal System

التحويل بين تلك الأنظمه

التحويل بين تلك الأنظمه العددية الإحتمالات : Decimal Octal Binary Hexadecimal pp. 40-46

التحويل بين تلك الأنظمه العددية التحويل من أي نظام إلي العشري: Decimal Octal Binary Hexadecimal

Quick Example 2510 = 110012 = 318 = 1916 Base

الثنائى للعشري ضرب كل خانه (Bit) في 2n , علما بأن n تمثل وزن الخانه. خطوات عملية التحويل: ضرب كل خانه (Bit) في 2n , علما بأن n تمثل وزن الخانه. وزن الخانه عباره عن رقم(مكان) الخانه ويبدأ من اليمين ويبدأ برقم صفر. إجمع النتائج.

(1 1 1)2 16 2 1 (19)10 مثال ON/OFF OFF OFF ON ON ON Exponent: 24 23 22 1 1)2 ON/OFF OFF OFF ON ON ON Exponent: 24 23 22 21 20 16 2 1 = Calculation: + + + + (19)10

Example Bit “0” 1010112 => 1 x 20 = 1 1 x 21 = 2 0 x 22 = 0 1 x 23 = 8 0 x 24 = 0 1 x 25 = 32 4310

الثمانى للعشري ضرب كل خانه (Bit) في 8n , علما بأن n تمثل وزن الخانه. خطوات عملية التحويل: ضرب كل خانه (Bit) في 8n , علما بأن n تمثل وزن الخانه. وزن الخانه عباره عن رقم(مكان) الخانه ويبدأ من اليمين ويبدأ برقم صفر. جمع النتائج.

مثال ( 4 7)8 1 Exponent: 82 81 80 1 8 64 64 32 7 = + + (103)10

Example 7248 => 4 x 80 = 4 2 x 81 = 16 7 x 82 = 448 46810

السداسي عشر للعشري خطوات عملية التحويل: ضرب كل خانه (Bit) في 16n , علما بأن n تمثل وزن الخانه. وزن الخانه عباره عن رقم(مكان) الخانه ويبدأ من اليمين ويبدأ برقم صفر. جمع النتائج.

مثال ( 4 7)16 1 Exponent: 162 161 160 1 16 256 256 64 7 = + + (327)10

Example ABC16 => C x 160 = 12 x 1 = 12 B x 161 = 11 x 16 = 176 A x 162 = 10 x 256 = 2560 274810

من النظام العشري لأي نظام اخر Decimal Octal Binary Hexadecimal

تمثيل الأرقام العشريه بالنظام الثنائي مجموع الأوزان بالقسمة علي 2

تمثيل الأرقام العشريه بالنظام الثماني مجموع الأوزان بالقسمة علي 8

تمثيل الأرقام العشريه بالنظام السداسي عشر مجموع الأوزان بالقسمة علي 16

من العشري للثنائي (باستخدام القسمه علي الاساس) خطوات عملية التحويل: أقسم الرقم علي 2 , سجل باقي القسمه. أول باقي يكون لـ bit 0 (LSB, least-significant bit) ثاني باقي يكون لـ bit 1. وهكذا.

Example 12510 = ?2 2 125 62 1 2 31 0 2 15 1 2 7 1 2 3 1 2 1 1 2 0 1 12510 = 11111012

من العشري للثماني(باستخدام القسمه علي الاساس) خطوات عملية التحويل: أقسم الرقم علي 8 , سجل باقي القسمه. أول باقي يكون لـ bit 0 (LSB, least-significant bit) ثاني باقي يكون لـ bit 1. وهكذا.

من العشري للسداسي عشر(باستخدام القسمه علي الاساس) خطوات عملية التحويل: أقسم الرقم علي 16 , سجل باقي القسمه. أول باقي يكون لـ bit 0 (LSB, least-significant bit) ثاني باقي يكون لـ bit 1. وهكذا.

التحويل بين الأنظمه الأخري عدا العشري

التحويل بين تلك الأنظمه العددية Decimal Octal Binary Hexadecimal

التحويل من الثنائي – الثماني / السداسي عشر الثنائي / الثماني: يتم التقسيم في مجموعات من 3 (10 111 011 001 . 101 110)2 = (2731.56)8 الثماني / الثنائي : إعكس الوضع السابق (2731.56)8 = (10 111 011 001 . 101 110)2 الثنائي / السداسي عشر: يتم التقسيم في مجموعات من 4 (101 1101 1001 . 1011 1000)2 = (5D9.B8)16 السادسي عشر / الثنائي: عكس (5D9.B8)16 = (101 1101 1001 . 1011 1000)2

أمثله حول الأعداد التاليه إلي المقابل لها ؟ a)(1A)16 ( )2 حول الأعداد التاليه إلي المقابل لها ؟ a)(1A)16 ( )2 b) (16)8 ( )2 c) (11001101)2 ( )16

تمثيل الأعداد الموجبه والسالبه

تمثيل الأعداد الموجبه والسالبه. طرق تمثيل إشارة الرقم الاشارة والقيمة Sign& Magnitude متمم الاثنين 2’s Complement متمم الواحد 1’s Complement

مثال علي طريقة الإشاره والقيمه  i) 8 bits binary number    a)  +7 = 0 0 0 0 0 1 1 1 –7 =(1 0 0 0 0 1 1 1)2 b)  –10 = 1 0 0 0 1 0 1 0 (+10 =(0 0 0 0 1 0 1 0)2 sign magnitude 0 => +ve 1 => –ve

ماهو المدي من القيم (الأرقام) التي تستطيع تمثيله؟ تمرين في حالة لدينا n-bit ممثل باستخدام الإشاره والقيمه, ماهو المدي من القيم (الأرقام) التي تستطيع تمثيله؟

5 bits for magnitude (value)   ii) 6 bits binary number   __ __ __ __ __ __ 5 bits for magnitude (value)   a)  +7 = 0 0 0 1 1 1 (–7 = 1 0 0 1 1 12) b)  –10 = 1 0 1 0 1 0 (+10 = 0 0 1 0 1 02) Sign bit 0 => +ve 1 => –ve

وبناء عليه اصبح لديك -510 بمتمم الواحد وهو 111110102 مثال: حول (-5) باستخدام متمم الواحد ممثلا بـ 8 bit الحل حول +5 ممثله بـ 8bits ==< 00000101 يتم تغيير كل بت من صفر لواحد والعكس. وبناء عليه اصبح لديك -510 بمتمم الواحد وهو 111110102

Exercise: Get the representation of ones complement (6 bit) for the following numbers: i) +710 ii) –1010 Solution: (+10)10 = 0010102 So, (-10)10 = 1101012 Solution: (+7) = 0001112

متمم الأثنين مثال: حول (-5) باستخدام متمم الأثنين ممثلا بـ 8 bit الحل حول +5 ممثله بـ 8bits ==< 00000101 يتم تغيير كل بت من صفر لواحد والعكس. أضف 1 علي الخانه الأولي وبناء عليه اصبح لديك -510 بمتمم الأثنين وهو 111110112

مقارنه بين (الإشاره والقيمه) معا المتمم 1’s or2’s (1/2) Example: 4-bit signed number (positive values) Important slide! Mark this!

مقارنه بين (الإشاره والقيمه) معا المتمم 1’s or2’s (2/2) Example: 4-bit signed number (negative values) Important slide! Mark this!

Twos complement Similar to ones complement, its positive number is same as sign-and-magnitude Representation of its negative number is obtained by adding 1 to the ones complement of the number.  

Exercise: Obtain representation of twos complement (6 bit) for the following numbers i) +710 ii)–1010 Solution: (+7) = 0001112 (same as sign-magnitude) Solution: (+10) 10 = 0010102 (-10) 10 = 1101012 + 12 = 1101102 So, twos compliment for –10 is 1101102

Exercise: Obtain representation for the following numbers Decimal Sign-magnitude Twos complement +7 +6 -4 -6 -7 +18 -18 -13 4 bits 8 bits

العمليات الحسابيه بالنظام الثنائي

2s Complement Addition/Subtraction (1/3) Algorithm for addition, A + B: Perform binary addition on the two numbers. Ignore the carry out of the MSB (most significant bit). Check for overflow: Overflow occurs if the ‘carry in’ and ‘carry out’ of the MSB are different, or if result is opposite sign of A and B. Algorithm for subtraction, A – B: A – B = A + (–B) Take 2s complement of B by inverting all the bits and adding 1. Add the 2s complement of B to A.

2s Complement Addition/Subtraction (2/3) Examples: 4-bit binary system Which of the above is/are overflow(s)? +3 0011 + +4 + 0100 ---- ------- +7 0111 -2 1110 + -6 + 1010 ---- ------- -8 11000 +6 0110 + -3 + 1101 ---- ------- +3 10011 +4 0100 + -7 + 1001 ---- ------- -3 1101

1s Complement Addition/Subtraction (1/2) Algorithm for addition, A + B: Perform binary addition on the two numbers. If there is a carry out of the MSB, add 1 to the result. Check for overflow: Overflow occurs if result is opposite sign of A and B. Algorithm for subtraction, A – B: A – B = A + (–B) Take 1s complement of B by inverting all the bits. Add the 1s complement of B to A.

1s Complement Addition/Subtraction (2/2) Examples: 4-bit binary system +3 0011 + +4 + 0100 ---- ------- +7 0111 +5 0101 + -5 + 1010 ---- ------- -0 1111 -2 1101 + -5 + 1010 ---- ------ -7 10111 ---- + 1 ------ 1000 -3 1100 + -7 + 1000 ---- ------- -10 10100 ---- + 1 ------- 0101

تمثيل الأعداد الكسريه

الخلاصه