نمايش اعداد علی عادلی.  مبنا ( base ): –مبناي r: ارقام محدود به [0, r-1]  دسيمال:(379) 10  باينري:(01011101) 2  اکتال:(372) 8  هگزادسيمال:(23D9F)

Slides:



Advertisements
Similar presentations
HEXADECIMAL NUMBERS Code
Advertisements

Company LOGO Edit your slogan here DKT 122/3 DIGITAL SYSTEM 1 WEEK #3 NUMBER SYSTEMS, OPERATION & CODES (PART 2)
ELEC353 S. al Zahir UBC Sign-Magnitude Representation High order bit is sign: 0 = positive (or zero), 1 = negative Low order bits represent the magnitude:
CHAPTER 2 Number Systems, Operations, and Codes
ECE 331 – Digital System Design
CS 151 Digital Systems Design Lecture 3 More Number Systems.
Number Systems Decimal (Base 10) Binary (Base 2) Hexadecimal (Base 16)
نمايش اعداد.
1 Binary Arithmetic, Subtraction The rules for binary arithmetic are: = 0, carry = = 1, carry = = 1, carry = = 0, carry =
Number Representation (1) Fall 2005 Lecture 12: Number Representation Integers and Computer Arithmetic.
نمايش اعداد.
VIT UNIVERSITY1 ECE 103 DIGITAL LOGIC DESIGN CHAPTER I NUMBER SYSTEMS AND CODES Reference: M. Morris Mano & Michael D. Ciletti, "Digital Design", Fourth.
ENGIN112 L3: More Number Systems September 8, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 3 More Number Systems.
MOHD. YAMANI IDRIS/ NOORZAILY MOHAMED NOOR 1 Overflow Signed binary is in fixed range -2 n-1  2 n-1 If the answer for addition/subtraction more than the.
1 Binary Numbers Again Recall that N binary digits (N bits) can represent unsigned integers from 0 to 2 N bits = 0 to 15 8 bits = 0 to bits.
Information Representation and Number Systems BIL- 223 Logic Circuit Design Ege University Department of Computer Engineering.
Data Representation – Chapter 3 Sections 3-2, 3-3, 3-4.
1 Lecture 2: Number Systems Binary numbers Base conversion Arithmetic Number systems  Sign and magnitude  Ones-complement  Twos-complement Binary-coded.
1.6 Signed Binary Numbers.
Dr. Bernard Chen Ph.D. University of Central Arkansas
ACOE1611 Data Representation and Numbering Systems Dr. Costas Kyriacou and Dr. Konstantinos Tatas.
Digital Systems and Logic Design
1 Digital Technology and Computer Fundamentals Chapter 1 Data Representation and Numbering Systems.
Binary Arithmetic & Data representation
1 Digital Systems and Binary Numbers EE 208 – Logic Design Chapter 1 Sohaib Majzoub.
EE2174: Digital Logic and Lab Professor Shiyan Hu Department of Electrical and Computer Engineering Michigan Technological University CHAPTER 2 Number.
ECEN2102 Digital Logic Design Lecture 1 Numbers Systems Abdullah Said Alkalbani University of Buraimi.
Digital Logic Design Lecture 3 Complements, Number Codes and Registers.
Topic: Arithmetic Circuits Course: Digital Systems Slide no. 1 Chapter # 5: Arithmetic Circuits.
CS151 Introduction to Digital Design
Information Representation. Digital Hardware Systems Digital Systems Digital vs. Analog Waveforms Analog: values vary over a broad range continuously.
Logic Design Dr. Yosry A. Azzam. Binary systems Chapter 1.
10-Sep Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Sept Representing Information in Computers:  numbers: counting numbers,
Number Systems Decimal (Base 10) –10 digits (0,1,2,3,4,5,6,7,8,9) Binary (Base 2) –2 digits (0,1) Digits are often called bits (binary digits) Hexadecimal.
Number systems & Binary codes MODULE 1 Digital Logic Design Ch1-2 Outline of Chapter 1  1.1 Digital Systems  1.2 Binary Numbers  1.3 Number-base Conversions.
1 EENG 2710 Chapter 1 Number Systems and Codes. 2 Chapter 1 Homework 1.1c, 1.2c, 1.3c, 1.4e, 1.5e, 1.6c, 1.7e, 1.8a, 1.9a, 1.10b, 1.13a, 1.19.
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.
BR 8/99 Binary Numbers Again Recall than N binary digits (N bits) can represent unsigned integers from 0 to 2 N bits = 0 to 15 8 bits = 0 to 255.
Chapter 1: Digital Computers and Information Illustration at beginning of each Chapter Base 10 Binary Base 2 Octal Base 8 Hex bas
Number Systems Decimal (Base 10) –10 digits (0,1,2,3,4,5,6,7,8,9) Binary (Base 2) –2 digits (0,1) Digits are often called bits (binary digits) Hexadecimal.
1 IT 231, CMPE 331 Digital Logic Design Week 2 Number systems and arithmetic.
ECE 2110: Introduction to Digital Systems Signed Addition/Subtraction.
طراحی مدارهای منطقی نیمسال دوم دانشگاه آزاد اسلامی واحد پرند.
1 Representation of Data within the Computer Oct., 1999(Revised 2001 Oct)
Number Systems and Digital Codes
ECE 331 – Digital System Design Representation and Binary Arithmetic of Negative Numbers and Binary Codes (Lecture #10) The slides included herein were.
Computer Math CPS120 Introduction to Computer Science Lecture 4.
AEEE2031 Data Representation and Numbering Systems.
Tutorial: ITI1100 Dewan Tanvir Ahmed SITE, UofO
ECE 301 – Digital Electronics Representation of Negative Numbers, Binary Arithmetic of Negative Numbers, and Binary Codes (Lecture #11) The slides included.
Assoc. Prof. Dr. Ahmet Turan ÖZCERİT.  The necessity and advantages of coding  The variety of coding systems You will learn: 2.
DIGITAL SYSTEMS Number systems & Arithmetic Rudolf Tracht and A.J. Han Vinck.
Chapter 1: Binary Systems
IT1004: Data Representation and Organization Negative number representation.
NUMBER SYSTEMS AND CODES. CS Digital LogicNumber Systems and Codes2 Outline Number systems –Number notations –Arithmetic –Base conversions –Signed.
1 Digital Logic Design Lecture 2 More Number Systems/Complements.
CCE Department – Faculty of engineering - Islamic University of Lebanon Chapter 6 Binary Arithmetic.
ECE DIGITAL LOGIC LECTURE 4: BINARY CODES Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2016, 01/26/2016.
Lecture 1.2 (Chapter 1) Prepared by Dr. Lamiaa Elshenawy
Nguyen Le CS147.  2.4 Signed Integer Representation  – Signed Magnitude  – Complement Systems  – Unsigned Versus Signed Numbers.
ECE 3110: Introduction to Digital Systems Signed Number Conversions and operations.
Computer Math CPS120 Introduction to Computer Science Lecture 7.
Number Systems. The position of each digit in a weighted number system is assigned a weight based on the base or radix of the system. The radix of decimal.
Lecture 4: Digital Systems & Binary Numbers (4)
COMPUTER ORGANIZATION 4 TH LECTURE. ASCII Code  ASCII ( American Standard Code for Information Interchange).  Input and output devices that communicate.
Chapter 3 Data Representation
نمايش اعداد در کامپيوتر چهار عمل اصلي
Data Representation – Chapter 3
ECE 331 – Digital System Design
Presentation transcript:

نمايش اعداد علی عادلی

 مبنا ( base ): –مبناي r: ارقام محدود به [0, r-1]  دسيمال:(379) 10  باينري:( ) 2  اکتال:(372) 8  هگزادسيمال:(23D9F) 16  نيازها: –محاسبات در هر سيستم –تبديل از يک سيستم به سيستم ديگر 2 سيستم نمايش اعداد

– اعداد دسيمال:  دو بخش صحيح و اعشاري A n-1 A n-2 … A 1 A 0. A -1 A -2 … A -m+1 A -m که A i عددي بين 0 تا 9 و با وزن 10 i است. 3 سيستم نمايش اعداد (دسيمال)

4 The value of A n-1 A n-2 … A 1 A 0. A -1 A -2 … A -m+1 A -m is calculated by  i=n-1..0 (A i  10 i ) +  i=-m..-1 (A i  10 i ) مثال: (126.53) 10 = 1* * * * *10 -2

 “base” r (radix r)  N = A n-1  r n-1 + A n-2  r n-2 +… + A 1  r + A 0 + A -1  r -1 + A -2  r -2 +… + A -m  r -m 5 سيستم نمايش اعداد (حالت کلي) Most Significant Digit (MSD) Least Significant Digit (LSD)

 مثال: r = 6 (312.4) 6 = 3     6 -1 = (116.66) 10 – تبديل از مبناي r به مبناي 10 با رابطة بالا انجام مي شود. 6 سيستم نمايش اعداد (حالت کلي)

–کامپيوترها داده ها را به صورت رشته اي از “بيت ها” نمايش مي دهند.  بيت: 0 يا 1 –مبناي 2: ارقام 0 يا 1  مثال: ( ) 2 = 1         2 -2 (in decimal) = ½ + 0 = (45.5) 10 7 اعداد باينري (مبناي 2)

 مثال: ( ) 2 = 1        2 -3 (in decimal) = = (9.375) 10 8 اعداد باينري (مبناي 2)

9 اعداد باينري ( )= ( ) BD

10 توان هاي 2 Memorize at least through 2 12

 مبناي 8: – ارقام 0 تا 7  مثال: (762) 8 = 7    8 0 (in decimal) = = (498) اعداد اکتال (مبناي 8)

 مبناي 16 : – ارقام 0, …, 9, A, B, C, D, E, F – A=10, B=11, …, F = 15  مثال: (3FB) 16 = 3    16 0 (in decimal) = = (1019) اعداد هگزادسيمال (مبناي 16)

– هر مبنا (r)  دسيمال: آسان (گفته شده) –دسيمال  هر مبناي r – دسيمال  باينري –اکتال  باينري و برعکس –هگزادسيمال  باينري و برعکس 13 تبديل مبناها

14 تبديل دسيمال به هر مبناي r بخش صحيح : تقسيم متوالي بر r خواندن باقيمانده ها به بالا , ,172rem rem 12 = C 16 8 rem 7 0 rem 8 Read up 34, = 87C , = (?) 16

15 تبديل دسيمال به هر مبناي r x 16 = 12.5 int = 12 = C 0.5 x 16 = 8.0 int = 8 Read down = 0.C8 16 بخش اعشاري : ضرب متوالي در r خواندن بخش صحيح ها به پايين = (?) 16

16 تبديل دسيمال به هر مبناي r 0.1 x 2 = 0.2 int = x 2 = 0.4 int = x 2 = 0.8 int = x 2 = 1.6 int = x 2 = 1.2 int = x 2 = 0.4 int = x 2 = 0.8 int = 0 Read down = مثالي ديگر = (?) 2

17 اعداد در مبناهاي مختلف Memorize at least Binary and Hex

 فرض: N يک عدد دسيمال 1.بزرگترين عددي که توان 2 است و با تفريق آن عددي مثبت (N 1 )حاصل مي شود پيدا کن. 2.يک عدد 1 در MSB قرار بده. 3.مرحلة 1 را با عدد N 1 تکرار کن.  در بيت مربوط عدد 1 قرار بده.  وقتي اختلاف صفر شد توقف کن. 18 دسيمال  باينري

 مثال:  N = (717) – 512 = 205 = N = –128 = 77 = N = – 64 = 13 = N 3 64 = – 8 = 5 = N 4 8 = – 4 = 1 = N 5 4 = – 1 = 0 = N 6 1 = 2 0  (717) 10 = = ( ) 2 19 دسيمال  باينري

 باينري به اکتال – 8 = 2 3  هر 3 بيت باينري به يک بيت اکتال تبديل مي شود.  باينري به هگزادسيمال – 16 = 2 4  هر 4 بيت باينري به يک بيت هگزادسيمال تبديل مي شود. 20 باينري به اکتال باينري به هگز

21 Binary  Octal ( ) 2 ( ) 8 ( ) 2

22 Binary  Hex ( 6 A8. F 5 C ) 16 ( ) 2 ( ) 2

23 Octal  Hex ازطريق باينري انجام دهيد : Hex  Binary  Octal Octal  Binary  Hex

24 تبديل ها (مثال) جدول را پر کنيد : DecimalBinaryOctalHex ??? ? ?? ??336.5? ???F9C7.A

 قوانين: مانند جمع دسيمال  با اين تفاوت که1+1 = 10  توليد نقلي –0+0 = 0(c0) (sum 0 with carry 0) –0+1 = 1+0 = 1(c0) –1+1 = 0(c1) –1+1+1 = 1(c1) Carry Augend Addend Result اعمال رياضي باينري: جمع

– اگر تعداد بيت ها = n و حاصل جمع n+1 بيت نياز داشته باشد   سرريز 26 سرريز (Overflow)

 قوانين: –0-0 = 1-1 = 0 (b0) (result 0 with borrow 0) –1-0 = 1 (b0) –0-1 = 1 (b1) –… Borrow1100 Minuend11011 Subtrahend01101 Result اعمال رياضي باينري: تفريق

– الگوريتم هاي اعمال رياضي مبناي 10 را به خاطر آوريد. – آنها را براي مبناي مورد نظر تعميم دهيد. – قانون مبناي مورد نظر را به کار بريد.  براي باينري: 1+1=10 28 کليد موفقيت

 نمايش اعداد مثبت: –در بيشتر سيستم ها يکسان است.  نمايش اعداد منفي: –اندازه-علامت (Sign magnitude) –مکمل 1 (Ones complement) –مکمل 2 (Twos complement)  در بيشتر سيستم ها: مکمل 2  فرض: –ماشين با کلمه هاي 4 بيتي:  16 مقدار مختلف قابل نمايش.  تقريباً نيمي مثبت، نيمي منفي. 29 نمايش اعداد

اندازه-علامت: 30 نمايش اعداد High order bit is sign: 0 = positive (or zero), 1 = negative Three low order bits is the magnitude: 0 (000) thru 7 (111) Number range for n bits = +/-2 n-1 -1 Representations for 0 Cumbersome addition/subtraction Must compare magnitudes to determine sign of result

مکمل 1: 31 نمايش اعداد N is positive number, then N is its negative 1's complement N = (2 - 1) - N n Example: 1's complement of 7 2 = = = = -7 in 1's comp. Shortcut method: simply compute bit wise complement >

مکمل 1: 32 نمايش اعداد Subtraction implemented by addition & 1's complement Still two representations of 0! This causes some problems Some complexities in addition

مکمل 2: 33 نمايش اعداد Only one representation for 0 One more negative number than positive number like 1's comp except shifted one position clockwise

مکمل 2: 34 نمايش اعداد N* = 2 - N n Example: Twos complement of 7 2 = = = repr. of -7 Example: Twos complement of = = = repr. of 7 4 sub Shortcut method: Twos complement = bitwise complement > > 1001 (representation of -7) > > 0111 (representation of 7)

 Here’s an easier way to compute the 2’s complement: 1.Leave all least significant 0’s and first 1 unchanged. 2.Replace 0 with 1 and 1 with 0 in all remaining higher significant bits. 35 مکمل 2 Examples: Examples: N = 1010 N = N = 1010 N = ’s complement 2’s complement unchangedcomplementunchangedcomplement

36 جمع و تفريق مکمل (-3) If )carry-in to sign = carry-out ( then ignore carry if )carry-in ≠ carry-out( then overflow Simpler addition scheme makes twos complement the most common choice for integer number systems within digital systems

37 جمع و تفريق مکمل 2 Why can the carry-out be ignored? -M + N when N > M: M* + N = (2 - M) + N = 2 + (N - M) n n Ignoring carry-out is just like subtracting 2 n After ignoring the carry, this is just the right twos compl. representation for -(M + N)! -M + -N where N + M < or = 2 n-1 -M + (-N) = M* + N* = (2 - M) + (2 - N) = 2 - (M + N) + 2 n n nn

38 سرريز Overflow Conditions Add two positive numbers to get a negative number or two negative numbers to get a positive number = =

39 سرريز Overflow Conditions Overflow Overflow No overflow No overflow Method 1: Overflow when carry in to sign ≠ carry out Method 2: Overflow when sign(A) = sign(B) ≠ sign (result)

40

 Shift-and-add algorithm, as in base 10  Check: 13 * 6 = ضرب باينري M’cand M’plier (1)00000 (2)01101 (3)01101 Sum

–A decimal code: Decimal numbers (0..9) are coded using 4-bit distinct binary words –Observe that the codes (decimal ) are NOT represented (invalid BCD codes) 42 Binary-Coded Decimal (BCD)

 To code a number with n decimal digits, we need 4n bits in BCD e.g. (365) 10 = ( ) BCD  This is different from converting to binary, which is (365) 10 = ( ) 2  Clearly, BCD requires more bits. BUT, it is easier to understand/interpret 43 Binary-Coded Decimal

44 BCD Addition Case 1:Case 2: Case 3: (0) 0110 (0) (0) 1011 (1) (1) 0001 (1) 7 WRONG! Note that for cases 2 and 3, adding a factor of 6 (0110) gives us the correct result.

 BCD addition is therefore performed as follows 1) Add the two BCD digits together using normal binary addition 2) Check if correction is needed a) 4-bit sum is in range of 1010 to 1111 b) carry out of MSB = 1 3) If correction is required, add 0110 to 4-bit sum to get the correct result;  BCD carry out = 1 45 BCD Addition (cont.)

 Similar to binary negative number representation except r = 10. –BCD 9’s complement  invert each BCD digit (0  9, 1  8, 2  7,3  6, …7  2, 8  1, 9  0) –BCD 10’s complement  -N  10 n - N; 9’s complement BCD Negative Number Representation

 Example: Add 448 and 489 in BCD (448 in BCD) (489 in BCD) (greater than 9, add 6) (carry 1 into middle digit) 1101 (greater than 9, add 6) (carry 1 into leftmost digit) (BCD coding of ) 47 BCD Addition (cont.) 0110

 مانند BCD ولي هر رقم +3 –جمع سرراست تر –self-comlpement code  (مکمل هر رقم = مکمل 9 آن) 48 Excess-3

–We also need to represent letters and other symbols  alphanumeric codes –ASCII = American Standard Code for Information Interchange. Also known as Western European –It contains 128 characters:  94 printable ( 26 upper case and 26 lower case letters, 10 digits, 32 special symbols)  34 non-printable (for control functions) –Uses 7-bit binary codes to represent each of the 128 characters 49 ASCII character code

50 ASCII Table Bell Tab Line Fd Crg Ret Null BkSpc Space Escape

51 ASCII Control Codes

–Established standard (16-bit alphanumeric code) for international character sets –Since it is 16-bit, it has 65,536 codes –Represented by 4 Hex digits –ASCII is between B Unicode

53 Unicode Table

54 Unicode 062B 1579 ث 062C 1580 ج 062D 1581 ح 062E 1582 خ س ش ص ض 063B C D E ك ل م ن 064B 1611 ً 064C 1612 ٌ 064D 1613 ٍ 064E 1614 َ ٓ ٔ ٕ B C D E ٣ ٤ ٥ ٦ 066B 1643 ٫ 066C 1644 ٬ 066D 1645 ٭ 066E 1646 ٮ ٳ ٴ ٵ ٶ 067B 1659 ٻ 067C 1660 ټ 067D 1661 ٽ 067E 1662 پ ڃ ڄ څ چ 068B 1675 ڋ 068C 1676 ڌ 068D 1677 ڍ 068E 1678 ڎ

–Parity coding is used to detect errors in data communication and processing  An 8 th bit is added to the 7-bit ASCII code –Even (Odd) parity: set the parity bit so as to make the # of 1’s in the 8-bit code even (odd) 55 ASCII Parity Bit

 For example: –Make the 7-bit code an 8-bit even parity code  –Make the 7-bit code an 8-bit odd parity code   Error Checking: –Both even and odd parity codes can detect an odd number of error.  An even number of errors goes undetected. 56 ASCII Parity Bit (cont.)

 Gray codes are minimum change codes –From one numeric representation to the next, only one bit changes –Applications:  Later. 57 Gray Codes

58 Gray Codes (cont.) Binary Gray Binary Gray Binary Gray