670 likes | 687 Views
CS111 – Fundamentals of CS Lecture 2 Binary System I. Mohammad El-Ramly, PhD 2017 Acadox.com/class/48372 Y1NVWG. دعاء.
E N D
CS111 – Fundamentals of CSLecture 2Binary System I Mohammad El-Ramly, PhD 2017 Acadox.com/class/48372 Y1NVWG
دعاء ربنا إننا سمعنا مناديا ينادى للإيمان فآمنا ، ربنا اغفر لنا ذنوبنا و كفر عنا سيئاتنا و توفنا مع الأبرار ، ربنا و آتنا ما وعدتنا على رسلك و لاتخزنا يوم القيامة إنك لا تخلف الميعاد
Homework of last time ….. • Join http://www.acadox.com/join/Y1NVWG • Do Assignment 0 (2 marks) • Formstudy groups of 5 and submit your names to me. • Read lecture 1 slides and chapter 0 from the book (0.1 and 0.2) • ReadWikipedia article on حاسوب • Watch Charles Babbage's Analytical Engine https://www.youtube.com/watch?v=QVxbNZWLP60 • Book a time for oral teston Tuesday • You will be tested in materials of the week before exam • Get familiar with Windows and MS Office
What we did in lecture 1 • Course Objectives • Overview of Curriculum • Course Administration • Course Assessment
Course Objectives • Learning the basic computer terminology • Learning about digital data representation • Learning about computer architecture • Learning problem solving and algorithms • Learn about computer networks and security • Acquiring computer literacy • Learning programming principles (applied with Python)
Course Contents Computer Basics Dr. Mohammad El-Ramly • Computer Overview • Binary System • Data Representation • Computer Architecture • Data Storage • Networks and Internet • Social Impact of Computers • Problem Solving • & Programming • Dr. NouhSabry • Problem Solving • Flowcharts • Algorithms • Programming
نصائح هامة للدارس فى كلية الحاسبات • حدد موقفك من الكلية • اعتمد على نفسك – اسأل و ابحث • تعرف على أكبر عدد ممكن من الناس • الصاحب ساحب – فأحسن اختيار أصحابك • لكل شئ وقته – فر من الفتن فرارك من الأسد • تابع الجديد – اقرأ الكتاب ، طالع المواقع ، خذ كورسا أونلاين • الدراسة ليست كل شئ – العب رياضة ، احفظ القرآن ، إطلع رحلة
كيف تنجح فى الكلية و فى حياتك أولا: نم مبكرا عقب العشاء 1- وجعلنا الليل لباسا وجعلنا النهار معاشا 2- اللهم بارك لأمتي في بكورها نام بكير فيق بكير شوف الصحة كيف بتصير http://www.huffingtonpost.com/rosie-osmun/go-to-bed-early_b_7157026.html
Lectures 2 & 3 Outline • Bits and bytes • Binary numbers • Binary operations • Binary fractions • Hexadecimal / Octal • Binary system for integers • Binary system for fractions • 2’s compliment and excess notations
Reading for this lecture • Computer Science: An Overview Section 1.5
What Will We Study? 2 H E 3 G 5 4 أ ب ت L Programs 1 Algorithms 4 5
I. The Magic Bits • A bit is a Binary Digit. • A bit is either 0or 1 • 8 bits = 1 byte • 1024 byte = KB • 1024 x 1024 = MB • In computer • Everything is represented in bits • Everything is measured in bytes.
I. The Magic Bits • A computer consists of: • A a “brain” or central processing unit, • RAM (memory) for temporary storage, • Long term storage devices (magnetic, optical, SSD), and • Input and output devices to i/o data • Computer components are made of ICs which are accumulations of transistors. • https://www.build-electronic-circuits.com/how-transistors-work/
Everything is bits …. • Bit Patterns are used to represent information • Numbers ….. 345, 2.87 • Text characters….. aBc, أب, +-* • Images • Sound • And others
How do I know what kind of data this is …… • Bit Patterns are used to represent information • 00000000 00000000 00000000 00000101 00000000 00000000 00000000 00001111 00000000 00000000 00000000 00011001
Where is the bit stored ? • Switch open = input logic state 0 • Switch closed = input logic state1 • Lamp off = output logic state 0 • Lamp on = output logic state1 Electric Circuit
Where is the bit stored ? A flip flop circuit for storing a bit in memory or processor
The Magic Bits …..The Digital Revolution • The digital revolution is an ongoing process of social, political, and economic change brought about by digital technology, such as computers and the Internet
The Digital Revolution • The second phase of the digital revolution materialized when the Internet was opened to public use: • WWW • Email • E-Commerce • E-Learning • VoIP • Social Media • Chatbots
Bits changed ….. • The way we shop • The way we communicate • The way we find information • The way we chat • The way learn • The way we rebel • The way we play
Why Binary? • It is easier to implement hardware to deal with binary values than to deal with 10 different values. • It can be represented by a transistor being off (0) or on (1). • It can be a magnetic stripe magnetized with North in one direction (0) or the opposite (1).
II. Base 10 counting system • We happened to use the current counting system, because we happened to have ten fingers. • If dinosaurs had ruled the earth, they would be happy to use a 8-based counting system.
Numbers • Ancient Africa • Notches on a bone. • Egyptians/Roman • Each magnitude is represented by a symbol. • Indian/Arabian (Modern numbering system) 1,475,268
Base 10 (Decimal numbers) • What does 157 mean? • 157 = 1 x 100 + 5 x 10 + 7 x 1 = 1 x 102 + 5 x 101 + 7 x 100
Binary Code • Imagine a specie that only has two fingers. how can they count? • A computer is such kind of two-finger specie. 0 and 1 • Each place is the exponential of 2
Base 10 vs Base 2 Base 10 157 157 = 1 x 100 + 5 x 10 + 7 x 1 = 1 x 102 + 5 x 101 + 7 x 100 Base 2 1011 = 1 x 23 + 0 x 22 + 1 x 21 + 1 x 20 1011 = 1 x 8 + 0 x 4 + 1 x 2 + 1 x 1
Binary Bits and Bytes • 1 bit is a single bit of information: • a 1 or 0 • Only two possible values • 1 byte is 8 bits, an 8 bit word • 256 possible values from 0-255 base 10 or 00000000 to 11111111 base 2 • 10100110 is a single byte
Converting Binary to Decimal = 64 + 16 + 2 = 82
An algorithm for finding the binary representation of a positive integer
III. Binary mathematics • Binary addition • Binary subtraction • Binary multiplication
Binary Addition • 0+0=0 • 1+0=1 • 1+1=10
Binary Subtraction 10 _ _ _ _
Binary Subtraction • 0-0=0 • 1-0=1 • 1-1=0 • 0-1=1 (borrow)