Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Cs101.lect15.binarynumbers.ppt, Study notes of Algorithms and Programming

binary numbers

Typology: Study notes

2014/2015

Uploaded on 07/30/2015

budz000
budz000 🇵🇭

1 document

1 / 17

Related documents


Partial preview of the text

Download Cs101.lect15.binarynumbers.ppt and more Study notes Algorithms and Programming in PDF only on Docsity! 1 1 Aaron Stevens 14 October 2010 CS101 Lecture 15: Number Systems and Binary Numbers 2 2 3 4 TODAY’S LECTURE CONTAINS TRACE AMOUNTS OF ARITHMETIC AND ALGEBRA PLEASE BE ADVISED THAT CALCULTORS WILL BE ALLOWED ON THE QUIZ (and that you probably won’t need them) !!! MATH WARNING !!! 5 9 5 It depends on the numbering system. 642 is 600 + 40 + 2 in BASE 10 The base of a number determines the number of digits (e.g. symbols) and the value of digit positions Numbering Systems 10 6 Continuing with our example… 642 in base 10 positional notation is: 6 x 102 = 6 x 100 = 600 + 4 x 101 = 4 x 10 = 40 + 2 x 10º = 2 x 1 = 2 = 642 in base 10 This number is in base 10 The power indicates the position of the number Positional Notation 6 11 7 dn * Bn-1 + dn-1 * Bn-2 + ... + d1 * B0 As a general form: 642 = 63 * 102 + 42 * 101 + 21 * 100 B is the base n is the number of digits in the number d is the digit in the ith position in the number Positional Notation 12 What Would Pooh Do? 7 13 9 Digital computers are made up of electronic circuits, which have exactly 2 states: on and off. Computers use a numbering system which has exactly 2 symbols, representing on and off. Binary Numbers 14 9 Decimal is base 10 and has 10 digits: 0,1,2,3,4,5,6,7,8,9 Binary is base 2 and has 2, so we use only 2 symbols: 0,1 For a given base, valid numbers will only contain the digits in that base, which range from 0 up to (but not including) the base. Binary Numbers 10 19 Try another one. What is the decimal equivalent of the binary number 10101011? (you try it! Work left-to-right) 13 Converting Binary to Decimal 20 Try another one. What is the decimal equivalent of the binary number 10101011? 1 x 27 = 1 x 128 = 128 + 0 x 26 = 0 x 64 = 0 + 1 x 25 = 1 x 32 = 32 + 0 x 24 = 0 x 16 = 0 + 1 x 23 = 1 x 8 = 8 + 0 x 22 = 0 x 4 = 0 + 1 x 21 = 1 x 2 = 2 + 1 x 2º = 1 x 1 = 1 = 171 (decimal) 13 Converting Binary to Decimal 11 21 While (the quotient is not zero) Divide the decimal number by the new base* Make the remainder the next digit to the left in the answer Replace the original decimal number with the quotient * Using whole number (integer) division only. Example: 3 / 2 gives us a quotient of 1 and a remainder 1 Algorithm (process) for converting number in base 10 to other bases 19 Converting from Decimal to Other Bases 22 Converting Decimal to Binary What is the binary equivalent of the decimal number 103? 103 / 2 = 51, remainder 1  rightmost bit 51 / 2 = 25, remainder 1 25 / 2 = 12, remainder 1 12 / 2 = 6, remainder 0 6 / 2 = 3, remainder 0 3 / 2 = 1, remainder 1 1 / 2 = 0, remainder 1 leftmost bit 103dec = 1 1 0 0 1 1 1bin 12 23 Converting Decimal to Binary Now you try one. What is the binary equivalent of the decimal number 201? Recall the algorithm: While (the quotient is not zero) Divide the decimal number by the new base* Make the remainder the next digit to the left in the answer Replace the original decimal number with the quotient 24 Converting Decimal to Binary What is the binary equivalent of the decimal number 201? 201 / 2 = 100, remainder 1  rightmost bit 100 / 2 = 50, remainder 0 50 / 2 = 25, remainder 0 25 / 2 = 12, remainder 1 12 / 2 = 6, remainder 0 6 / 2 = 3, remainder 0 3 / 2 = 1, remainder 1 1 / 2 = 0, remainder 1 leftmost bit 201dec = 1 1 0 0 1 0 0 1bin 15 29 Conversions Between Number Systems Try some! http://www.mathsisfun.com/binary-decimal- hexadecimal-converter.html My phone number: 0x16FF96419 (or: 0001 0110 1111 1111 1001 0110 0100 0001 1001) 30 16 31 What You Learned Today – Encoding: Symbols Represent Values – Number Systems – Binary Numbers, Bits, and Bytes – Algorithms: converting binary to decimal and vice versa – Encoding: Hexadecimal 32 Announcements and To Do List –HW06 due Wednesday 10/20 –Readings: • Reed ch 5, pp 83-87, 89-90 (today) • Wong ch 1 pp 13-19 (next week) • Wong ch 2, pp 26-44 – QUIZ 3 will be on TUESDAY 10/19 • Covers networking, binary numbers, text (lectures 11-16) 17 33 Want to learn more? If you’ve read this far, maybe you’d like to learn about other binary representations of other types of numbers? Read about this on Wikipedia and we can discuss your questions: – Two’s complement (negative numbers) – IEE754 (real numbers)
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved