Binary Numbers.

Slides:



Advertisements
Similar presentations
Department of Computer and Information Science, School of Science, IUPUI CSCI 240 Digital Logic.
Advertisements

(CSC 102) Discrete Structures Lecture 5.
Combinational Circuits ENEL 111. Common Combinationals Circuits NAND gates and Duality Adders Multiplexers.
CSC 110 – Intro to Computing Lecture 14: Midterm Review.
Part 2: DESIGN CIRCUIT. LOGIC CIRCUIT DESIGN x y z F F = x + y’z x y z F Truth Table Boolean Function.
Number Systems & Logic Gates Day 2. Octal Number System Base (Radix)8 Digits0, 1, 2, 3, 4, 5, 6, 7 e.g = =648 1 =88 0 =1 The digit.
CMSC 104, Version 9/01 1 Machine Architecture and Number Systems Topics Major Computer Components Bits, Bytes, and Words The Decimal Number System The.
XOR, XNOR, and Binary Adders
Lecture 3. Boolean Algebra, Logic Gates Prof. Sin-Min Lee Department of Computer Science 2x.
1 Survey of Computer Science CSCI 110, Spring 2011 Lecture 16 Digital Circuits, binary Numbers.
(2.1) Fundamentals  Terms for magnitudes – logarithms and logarithmic graphs  Digital representations – Binary numbers – Text – Analog information 
Computers Organization & Assembly Language
1 Machine Architecture and Number Systems Topics Major Computer Components Bits, Bytes, and Words The Decimal Number System The Binary Number System Converting.
1 CHAPTER 4: PART I ARITHMETIC FOR COMPUTERS. 2 The MIPS ALU We’ll be working with the MIPS instruction set architecture –similar to other architectures.
Gates and Circuits Monday/Wednesday Week 7. Electronic Circuits  Two types of circuit diagrams See pp. 238 in The Analytical Engine by Decker and Hirshfield.
Binary Addition CSC 103 September 17, 2007.
XOR and XNOR Logic Gates. XOR Function Output Y is TRUE if input A OR input B are TRUE Exclusively, else it is FALSE. Logic Symbol  Description  Truth.
Basic Arithmetic (adding and subtracting)
Computer Organization 1 Logic Gates and Adders. Propositions –Venn Diagrams.
Basic Arithmetic (adding and subtracting)
Number systems, Operations, and Codes
CMSC 104, Lecture 051 Binary / Hex Binary and Hex The number systems of Computer Science.
Logic Gates Logic gates are electronic digital circuit perform logic functions. Commonly expected logic functions are already having the corresponding.
Logic Gates Shashidhara H S Dept. of ISE MSRIT. Basic Logic Design and Boolean Algebra GATES = basic digital building blocks which correspond to and perform.
Sneha.  Gates Gates  Characteristics of gates Characteristics of gates  Basic Gates Basic Gates  AND Gate AND Gate  OR gate OR gate  NOT gate NOT.
4. Computer Maths and Logic 4.2 Boolean Logic Logic Circuits.
Digital Logic. 2 Abstractions in CS (gates) Basic Gate: Inverter IO IO GNDI O Vcc Resister (limits conductivity) Truth Table.
Lecture 4 Nand, Nor Gates, CS147 Circuit Minimization and
1 EG 32 Digital Electronics Thought for the day You learn from your mistakes..... So make as many as you can and you will eventually know everything.
Half Adder & Full Adder Patrick Marshall. Intro Adding binary digits Half adder Full adder Parallel adder (ripple carry) Arithmetic overflow.
1 Ethics of Computing MONT 113G, Spring 2012 Session 5 Binary Addition.
1 Ethics of Computing MONT 113G, Spring 2012 Session 1 Digital Circuits, binary Numbers Course webpage:
Machine Architecture and Number Systems
5 - Digital Logic with Boolean Algebra
Binary Decimal Hexadecimal
Department of Preparatory Year, Umm Al Qura University CSCI 240 Digital Logic.
Number Systems. Topics  The Decimal Number System  The Binary Number System  Converting from Binary to Decimal  Converting from Decimal to Binary.
LOGIC CIRCUITLOGIC CIRCUIT. Goal To understand how digital a computer can work, at the lowest level. To understand what is possible and the limitations.
Digital Logic. Boolean Algebra to Logic Gates Logic circuits are built from components called logic gates. The logic gates correspond to Boolean operations.
UMBC CMSC 104 – Section 01, Fall UMBC CMSC 104, Section 01 - Fall 2016  Nothing. Enjoy your weekend! 2.
Logic Gates Learning Objectives Learn that there is a one-to-one relationship between logic gates and Boolean expressions Learn how logic gates are combined.
Morgan Kaufmann Publishers
Department of Preparatory Year, Umm Al Qura University
Fundamentals & Ethics of Information Systems IS 201
University of Gujrat Department of Computer Science
Summary Half-Adder Basic rules of binary addition are performed by a half adder, which has two binary inputs (A and B) and two binary outputs (Carry out.
XOR, XNOR, and Binary Adders
Boolean Algebra & Logic Circuits
Basic Logic Gates 1.
CISC101 Reminders Your group name in onQ is your grader’s name.
XOR, XNOR, & Binary Adders
ELL100: INTRODUCTION TO ELECTRICAL ENGG.
Number Systems Decimal (base 10) { }
Boolean Algebra.
Week 7: Gates and Circuits: PART II
Machine Architecture and Number Systems
Logic Gates.
Logic Gates.
DIGITAL ELECTRONICS B.SC FY
Machine Architecture and Number Systems
Machine Architecture and Number Systems
XOR, XNOR, and Binary Adders
CMSC250 Fall 2018 Circuits 1 1.
Special Gates Combinational Logic Gates
XOR Function Logic Symbol  Description  Truth Table 
Notes from Last Class Office Hours: GL Accounts?
XOR, XNOR, and Binary Adders
UNIT – 3 & 4. Data Representation and Internal
Machine Architecture and Number Systems
Presentation transcript:

Binary Numbers

Outcome Familiar with the binary system Binary to Decimal and decimal to binary Adding two binary sequences Logic gates Hexadecimal system

Reading http://www.math.grin.edu/~rebelsky/Courses/152/97F/Readings/student-binary http://en.wikipedia.org/wiki/Binary_numeral_system http://www.cut-the-knot.org/do_you_know/BinaryHistory.shtml http://www.binarymath.info/

The Decimal Number System The decimal number system is also known as base 10. The values of the positions are calculated by taking 10 to some power. Why is the base 10 for decimal numbers? Because we use 10 digits, the digits 0 through 9.

The Decimal Number System - base 10 The decimal number system is a positional number system with a base 10. Example: 1011 10112 = 1000 + 000 + 10 + 1 = 1 x 23 + 0 x22 + 1 x 21 + 1 x 20 = 1110 1000 000 10 1 1 x 23 0x22 1 x 21 1x 20

The Binary Number System The binary number system is also known as base 2. The values of the positions are calculated by taking 2 to some power. Why is the base 2 for binary numbers? Because we use 2 digits, the digits 0 and 1.

The Binary Number System – base 2 The decimal number system is a positional number system with a base 10. Example: 5623 5623 = 5000 + 600 + 20 + 3 = 5 x 103 + 6 x102 + 2 x 101 + 3 x 100 5000 600 20 3 5 x 103 6 x102 2 x 101 3 x 100

Why Bits (Binary Digits)? Computers are built using digital circuits Inputs and outputs can have only two values True (high voltage) or false (low voltage) Represented as 1 and 0 Can represent many kinds of information Boolean (true or false) Numbers (23, 79, …) Characters (‘a’, ‘z’, …) Pixels Sound Can manipulate in many ways Read and write Logical operations Arithmetic …

Base 10 and Base 2 Base 10 Base 2 Each digit represents a power of 10 5417310 = 5 x 104 + 4 x 103 + 1 x 102 + 7 x 101 + 3 x 100 Base 2 Each bit represents a power of 2 101012= 1 x 24 + 0 x 23 + 1 x 22 + 0 x 21 + 1 x 20 = 2110

The Binary Number System (con’t) The binary number system is also a positional numbering system. Instead of using ten digits, 0 - 9, the binary system uses only two digits, 0 and 1. Example of a binary number and the values of the positions: 1 0 0 1 1 0 1 26 25 24 23 22 21 20

Converting from Binary to Decimal 1 0 0 1 1 0 1 1 X 20 = 1 26 25 24 23 22 21 20 0 X 21 = 0 1 X 22 = 4 20 = 1 1 X 23 = 8 21 = 2 0 X 24 = 0 22 = 4 0 X 25 = 0 23 = 8 1 X 26 = 64 24 = 16 7710 25 = 32 26 = 64

Converting from Binary to Decimal (con’t) Practice conversions: Binary Decimal 11101 1010101 100111

Converting From Decimal to Binary (con’t) Make a list of the binary place values up to the number being converted. Perform successive divisions by 2, placing the remainder of 0 or 1 in each of the positions from right to left. Continue until the quotient is zero. Example: 4210 25 24 23 22 21 20 32 16 8 4 2 1 1 0 1 0 1 0 42/2 = 21 and R = 0 21/2 = 10 and R = 1 10/2 = 5 and R = 0 5/2 = 2 and R = 1 2/2 = 1 and R = 0 1/2 = 0 and R = 1 4210 = 1010102

Example 1210 We repeatedly divide the decimal number by 2 and keep remainders 12/2 = 6 and R = 0 6/2 = 3 and R = 0 3/2 = 1 and R = 1 1/2 = 0 and R = 1 The binary number representing 12 is 1100

Converting From Decimal to Binary (con’t) Practice conversions: Decimal Binary 59 82 175

Exercises Find the binary the decimal number represented by the following binary sequences: 110101 10111010 Represent the number 135 in base 2.

Bits, Bytes, and Words A bit is a single binary digit (a 1 or 0). A byte is 8 bits A word is 32 bits or 4 bytes Long word = 8 bytes = 64 bits Quad word = 16 bytes = 128 bits Programming languages use these standard number of bits when organizing data storage and access.

Adding Two Integers: Base 10 From right to left, we add each pair of digits We write the sum, and add the carry to the next column 0 1 1 + 0 0 1 Sum Carry 1 9 8 + 2 6 4 Sum Carry 4 6 1 2 1 1 1 1

Example 10011110 1101111 + + 111 1101 -------------------- ------------------- = 101 0 0 101 = 1111100

Boolean Algebra to Logic Gates Logic circuits are built from components called logic gates. The logic gates correspond to Boolean operations +, *, ’. Binary operations have two inputs, unary has one OR + AND * NOT ’

AND A Logic Gate: A*B B Truth Table: A B A*B 1

OR A Logic Gate: A+B B Truth Table: A B A+B 1

NOT Logic Gate: (also called an inverter) A A’ or A Truth Table: a A 1

n-input Gates Because + and * are binary operations, they can be cascaded together to OR or AND multiple inputs. A A B A+B+C ABC B C A A B A+B+C ABC B C C

n-bit Inputs For convenience, it is sometimes useful to think of the logic gates processing n-bits at a time. This really refers to n instances of the logic gate, not a single logic date with n-inputs. 1101100101 1101110111 0100110111 10001111 00001100 00111100 110001 001110

Logic Circuits ≡ Boolean Expressions All logic circuits are equivalent to Boolean expressions and any boolean expression can be rendered as a logic circuit. AND-OR logic circuits are equivalent to sum-of-products form. Consider the following circuits: A y=aB+Bc abc B C A B C Y aBc y Ab y=abc+aBc+Ab

NAND and NOR Gates NAND and NOR gates can greatly simplify circuit diagrams. As we will see, can you use these gates wherever you could use AND, OR, and NOT. A B AB 1 NAND A B AB 1 NOR

XOR and XNOR Gates XOR is used to choose between two mutually exclusive inputs. Unlike OR, XOR is true only when one input or the other is true, not both. A B AB 1 XOR A B A B 1 XNOR

Binary Sums and Carries a b Sum a b Carry 0 0 0 0 0 0 0 1 1 0 1 0 1 0 1 1 0 0 1 1 0 1 1 1 XOR AND 0100 0101 69 + 0110 0111 103 1010 1100 172

Half Adder (1-bit) A B A B S(um) C(arry) 1 S Half Adder C

Half Adder (1-bit) A B S(um) C(arry) 1 A B Sum Carry

Full Adder A B Cin A B S(um) Cout 1 S Full Adder Carry In (Cin) Cout

Full Adder H.A. H.A. A B Cin Cout S

Full Adder Cout S Half Adder C A B Cin

4-bit Ripple Adder using Full Adder Cin Cout S S3 A3 B3 Carry Full Adder A B Cin Cout S S2 A2 B2 Full Adder A B Cin Cout S S1 A1 B1 A0 B0 Full Adder A B Cin Cout S A B Cin Cout S H.A. Full Adder S0 A B S C Half Adder

Working with Large Numbers 0 1 0 1 0 0 0 0 1 0 1 0 0 1 1 1 = ? Humans can’t work well with binary numbers; there are too many digits to deal with. Memory addresses and other data can be quite large. Therefore, we sometimes use the hexadecimal number system.

The Hexadecimal Number System The hexadecimal number system is also known as base 16. The values of the positions are calculated by taking 16 to some power. Why is the base 16 for hexadecimal numbers ? Because we use 16 symbols, the digits 0 and 1 and the letters A through F.

The Hexadecimal Number System (con’t) Binary Decimal Hexadecimal Binary Decimal Hexadecimal 0 0 0 1010 10 A 1 1 1 1011 11 B 10 2 2 1100 12 C 11 3 3 1101 13 D 100 4 4 1110 14 E 101 5 5 1111 15 F 110 6 6 111 7 7 1000 8 8 1001 9 9

The Hexadecimal Number System (con’t) Example of a hexadecimal number and the values of the positions: 3 C 8 B 0 5 1 166 165 164 163 162 161 160

Example of Equivalent Numbers Binary: 1 0 1 0 0 0 0 1 0 1 0 0 1 1 12 Decimal: 2064710 Hexadecimal: 50A716 Notice how the number of digits gets smaller as the base increases.

Summary Convert binary to decimal Decimal to binary Binary operation Logic gates Use of logic gates to perform binary operations Hexadecimal