تﺎﻣوظﻧﻣﻟاو تﺎﺑﺳﺎﺣﻟا 1 ﺔﺟﻣرﺑﻟاو ... · 2020-03-03 · 39...
TRANSCRIPT
1Copyright©2016Dr.Ing.MohammedNourAbdelgwad Ahmedaspartofthecourseworkandlearningmaterial.AllRightsReserved.Whereotherwisenoted,thisworkislicensedunderaCreativeCommonsAttribution-NonCommercial-ShareAlike 4.0InternationalLicense.
CSE1001برمجة الحاسبات وال
والمنظوماتالحاسبات قسم ھندسة –الھندسةكلیة –جامعة الزقازیق
نورعبدالجوادمحمد / د[email protected]
https://mnourgwad.github.io/CSE100
IIالحاسبتمثیل البیانات داخل : 3 المحاضرة
2
.العشريعداالتحویل بین األنظمة العددیة
تمثیل االرقام السالبةالعملیات الحسابیھ بالنظام الثنائي
المحاضرة الثالثھللیوم األھداف
)نقطھ المعومھال( كسریھالمثیل األعداد ت
3
األخري التحویل بین األنظمھعدا العشري
4
Hexadecimal
Decimal Octal
Binary
التحویل بین تلك األنظمھ العددیة
5
• 8=23
• Eachgroupof3 bitsrepresentsanoctaldigit
Octal Binary
0 0 0 0
1 0 0 1
2 0 1 0
3 0 1 1
4 1 0 0
5 1 0 1
6 1 1 0
7 1 1 1
Example:
( 1 0 1 1 0 . 0 1 )2
( 2 6 . 2 )8
Assume Zeros
الثماني–التحویل الثنائي
6
• 16=24
• Eachgroupof4 bitsrepresentsahexadecimaldigit
Hex Binary0 0 0 0 01 0 0 0 12 0 0 1 03 0 0 1 14 0 1 0 05 0 1 0 16 0 1 1 07 0 1 1 18 1 0 0 09 1 0 0 1A 1 0 1 0B 1 0 1 1C 1 1 0 0D 1 1 0 1E 1 1 1 0F 1 1 1 1
Example:
( 1 0 1 1 0 . 0 1 )2
( 1 6 . 4 )16
Assume Zeros
السداسي عشر–التحویل الثنائي
7
• ConverttoBinary asanintermediatestep
Example:
( 0 1 0 1 1 0 . 0 1 0 )2
( 1 6 . 4 )16
Assume Zeros
( 2 6 . 2 )8
Assume Zeros
السداسي عشر–التحویل الثماني
8
مثال
7058 = ?2
7 0 5
111 000 101
7058 = 1110001012
9
مثال
10AF16 = ?2
1 0 A F
0001 0000 1010 1111
10AF16 = 00010000101011112
10
مثال
10768 = ?161 0 7 6
001 000 111 110
2 3 E
10768 = 23E16
11
مثال
11
1F0C16 = ?81 F 0 C
0001 1111 0000 11001 7 4 1 4
1F0C16 = 174148
12
شرالسداسي ع/ الثماني –التحویل من الثنائي
13
تمثیل األعدادالموجبھ والسالبھ
14
تمثیل األعداد الموجبة والسالبة
طرق تمثیل إشارة الرقم
االشارة والقیمةSign&Magnitude
متمم االثنین2’sComplement
متمم الواحد1’sComplement
15
8 bits binary number
+7 =(0 0000111)2–7= (1 0 00 0 1 1 1)2–10=(1 0001010)2+10=(0 0001010)2
طریقة اإلشارة والقیمة
Sign 0 => +ve, 1 => –vemagnitude
16
متمم الواحد: األرقام السالبة
bit 8باستخدام متمم الواحد ممثال بـ (12-)حول :مثال
8bits ==< 00001100بـ ممثلھ 12+ حول1).یتم تغییر كل بت من صفر لواحد والعكس2)
)-x-n2= x–1(:متمم الواحد
17
متمم األثنین: األرقام السالبة
bit 8باستخدام متمم األثنین ممثال بـ (12-)حول :مثالالحل
8bits ==< 00001100بـ ممثلھ 12+ حول1).یتم تغییر كل بت من صفر لواحد والعكس2)1یتم جمع 3)
)-x-n2= x( : متمم األثنین
18
n-bitفي حالة لدینا
التي تستطیع) األرقام(من القیم ما ھو المديتمثیلھ؟
19
مدي تمثیل األرقام الموجیھ والسالبھ
أكبر رقم سالب موجب أكبر رقم
-(2n-1-1) (2n-1-1) و القیمھ األشارهSign&Mag.
-(2n-1-1) (2n-1-1) متمم الواحد1’sComp.
-(2n-1) (2n-1-1) متمم األثنین2’sComp.
20
العملیات الحسابیھبالنظام الثنائي
21
)متمم األثنین/(الطرح -الجمع:B+Aخطوات الجمع §
قم بالجمع الثنائي للرقمین1.
یتم إھمال الباقي إذا وجد2.
–A: خطوات الطرح§ B=A+(–B)
من خالل Bبالحصول علي متمم االثنین للرقم قم 1.1إضافةقیمة كل خانھ ثم قلب
.Aإلي Bقم بجمع متمم االثنین الخاص بـ 2.
22
:.comps’2العملیة باستخدام
0 0 11101111 0 −0011 0 01
177=
23=
(-23)=
00
+1
1 010110
1001011+
1
−
23
)متمم األثنین/(الطرح -الجمع
بت 4قم بإجراء العملیات الحسابیھ التالیھ ممثلھ بـ : أمثلھ§+3 0011
+ +4 + 0100---- ------+7 0111
-2 1110+ -6 + 1010---- --------8 11000
+6 0110+ -3 + 1101---- ------+3 10011
+4 0100+ -7 + 1001---- --------3 1101
24
)متمم الواحد/(الطرح -الجمع
:B+Aخطوات الجمع §قم بالجمع الثنائي للرقمین1..قم بإضافة الباقي إذا وجد علي الناتج2.
–Aخطوات الطرح§ B=A– B=A+(–B).من خالل قلب كل خانھ Bقم بالحصول علي متمم الواحد لـ 1..Aإلي Bبجمع متمم الواحد الخاص بـ قم 2.
25
)متمم الواحد/(الطرح -الجمع
+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
بت 4قم بإجراء العملیات الحسابیة التالیة ممثلھ بـ : أمثلھ§
26
الكسریھتمثیل األعداد )النقطھ المعومھ(
27
األعداد الكسریةتمثیل
1:مثال
2
3
4
1256.3= 125.63 X 10 = 12.563 X 10 = 1.2563 X 10 = 0.12563 X 10
إشارة الرقم+
ھتمثیل األس بإشارت+4
قیمة الرقم12563
Sign ofmantissa
Exponent Mantissa
28
:تمثیل األعداد الكسریھ)Floating Point(طریقة النقطھ المعومھ
:مثال+0.10111x2+3
0 00011 101110000
Sign ofmantissa
Exponent(5bits)
Mantissa(9bits)
29
:تمثیل األعداد الكسریھ)Floating Point(طریقة النقطھ المعومھ
:مثال-0.10111x2-3
1 11101 101110000
Sign ofmantissa
Exponent(5bits)
Mantissa(9bits)
30
:تمثیل األعداد الكسریھ)Floating Point(طریقة النقطھ المعومھ
31
:تمثیل األعداد الكسریھ
0.125= وبناء علیھ فإن الخطأ المطلق 100.25قیمة العدد الممثل ھي
:لتحسین ذلك الخطأØ6بدال من 5 عدد خانات األس لتصبح نقترح تخفیضØ9بدال من 10ثم زیادة عدد خانات تمثیل الرقم لتصبح
32
BCDANDASCIICODE
33
BinaryCodes
§“Ann-bitbinarycodeisagroupofn bitsthatassumeupto2n distinctcombinationsof1sand0s,witheachcombinationrepresentingoneelementofthesetbeingcoded”
§Forthe10digitsneeda4bitcode.OnecodeiscalledBinaryCodedDecimal(BCD)
34
BinaryCodedDecimal(BCD)
§TheBCDissimplythe4bitrepresentationofthedecimaldigit.
§Formultipledigitbase10numbers,eachsymbolisrepresentedbyitsBCDdigit
§Whathappenedto6digitsnotused?
35
•BCDfor417to195(417)10 =(0100 00010111)BCD
(195)10 =(000110010101)BCD
BinaryCodedDecimal(BCD)
36
AlphanumericCodes
Howdoyouhandlealphanumericdata?§Formulateabinarycodetorepresentcharacters!J
§Forthe26letterofthealphabetwouldneed5bitforrepresentation.
§Butwhatabouttheuppercaseandlowercase,andthedigits,andspecialcharacters
37
AcodecalledASCII
§ASCIIstandsforAmericanStandardCodeforInformationInterchange
§Thecodeuses7bitstoencode128uniquecharacters
Asanote,formally,worktocreatethiscodebeganin1960.1ststandardin1963.Lastupdatedin1986.
38
39
ASCIICode
§Representsthenumbers• Allstart011xxxx andthexxxx istheBCDforthedigit
§Representthecharactersofthealphabet• Startwitheither100,101,110,or111
§Afewspecial charactersareinthisarea• Startwith010– spaceand!”#$%&’()*+.-,/• Startwith000or001– controlcharlikeESC
40
ASCIIExample
§Encodingof123011000101100100110011
§EncodingofJoanne100101011011111100001110111011011101100101
§Notethattheseare7bitcodes
41
Whattodowiththe8th Bit?
§Indigitalsystemsdataisusuallyorganizedasbytesor8bitofdata.
§Howaboutusingthe8thbitforanerrorcoding.Thiswouldhelpduringdatatransmission,etc.
§Paritybit– theextrabitincludedtomakethetotalnumberof1sinthebyteeitherevenorodd– calledevenparityandoddparity
42
ExampleofParity
§Considerdata 1000001• EvenParity 01000001• OddParity 1100 0001
§Considerdata1010100• EvenParity 11010100• OddParity 01010100
§AparitycodecanbeusedforASCIIcharactersandanybinarydata.