Binary / Hex Binary and Hex The number systems of Computer Science.

Slides:



Advertisements
Similar presentations
HEXADECIMAL NUMBERS Code
Advertisements

Number Systems Discussion D4.1 Appendix C. Number Systems Counting in Binary Positional Notation Hexadecimal Numbers Negative Numbers.
Agenda Shortcuts converting among numbering systems –Binary to Hex / Hex to Binary –Binary to Octal / Octal to Binary Signed and unsigned binary numbers.
Number Systems and Codes Discussion D4.1. Number Systems Counting in Binary Positional Notation Hexadecimal Numbers Negative Numbers.
Number System and Codes
1 Number Systems. 2 Numbers Each number system is associated with a base or radix – The decimal number system is said to be of base or radix 10 A number.
The Binary Number System
COE 202: Digital Logic Design Number Systems Part 1
Binary and Hexadecimal Numbers
ES 244: Digital Logic Design Chapter 1 Chapter 1: Introduction Uchechukwu Ofoegbu Temple University.
EKT 121 / 4 ELEKTRONIK DIGIT 1 CHAPTER 1 : INTRODUCTION.
1 Number SystemsLecture 8. 2 BINARY (BASE 2) numbers.
The number systems of Computer Science
EX_01.1/46 Numeric Systems. EX_01.2/46 Overview Numeric systems – general, Binary numbers, Octal numbers, Hexadecimal system, Data units, ASCII code,
Chapter 2: The Logic of Compound Statements 2.5 Application: Number Systems and Circuits for Addition 1 Counting in binary is just like counting in decimal.
Number systems, Operations, and Codes
Numbering System Base Conversion. Number systems Decimal – 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Binary – 0, 1 Octal – 0, 1, 2, 3, 4, 5, 6, 7 Hexadecimal system.
Number Representation. Representing numbers n Numbers are represented as successive powers of a base, or radix.
CMSC 104, Lecture 051 Binary / Hex Binary and Hex The number systems of Computer Science.
CPS120: Introduction to Computer Science Computer Math: Converting to Decimal.
Lecture 2 Binary Values and Number Systems. The number 943 is an example of a number written in positional notation. The relative positions of the digits.
Converting From decimal to Binary & Hexadecimal to Binary
Number Systems Binary to Decimal Octal to Decimal Hexadecimal to Decimal Binary to Octal Binary to Hexadecimal Two’s Complement.
Scientific and standard notation, conversion
AP Computer Science A – Healdsburg High School 1 Unit 1 - Binary Numbers - Hexadecimal Numbers.
Chapter 2 Bits, Data Types, and Operations. 2-2 Hexadecimal Notation It is often convenient to write binary (base-2) numbers as hexadecimal (base-16)
Binary01.ppt Decimal Decimal: Base 10 means 10 Unique numerical digits ,00010,000 Weight Positions 3,
PHY 107 – Programming For Science. Positional Notation  Used in nearly all modern numerical systems  Right-to-left ordering of digits within larger.
MECH1500 Chapter 3.
Number Systems. Topics  The Decimal Number System  The Binary Number System  Converting from Binary to Decimal  Converting from Decimal to Binary.
Number Representation 1 Lecture 2. Outcomes By the end of the session you should: – Understand what bits/bytes/words are. – Understanding conversion between.
The Hexadecimal System is base 16. It is a shorthand method for representing the 8-bit bytes that are stored in the computer system. This system was chosen.
CMSC 1041 Binary / Hex Binary and Hex The number systems of Computer Science.
Numbering Systems and Conversion Understand How Computing Devices Work 1.
Number Systems Decimal Can you write 12,045 in expanded form? Base? Allowable digits for each place?
Nat 4/5 Computing Science Lesson 1: Binary
Programmable Logic Controller
Introduction To Number Systems
Binary, Denary, Hexadecimal Conversion Binary Addition
Digital Logic and Computer Organization
Unit 18: Computational Thinking
Number Systems and Binary Arithmetic
What is a byte? What is it? How would you use it?
Integer Real Numbers Character Boolean Memory Address CPU Data Types
CHAPTER 1 : INTRODUCTION
Number Systems.
CSE 102 Introduction to Computer Engineering
2.0 COMPUTER SYSTEM 2.2 Number System and Representation
Number System conversions
Addition and Substraction
Fundamentals of Programming I Number Systems
Digital Logic Design (ECEg3141) 2. Number systems, operations & codes 1.
Digital Electronics and Microprocessors
Negatives, Addition, Subtraction
Chapter 2: Number Systems
Binary Lesson 3 Hexadecimal
Decimal and binary representation systems
Binary Lesson 3 Hexadecimal
Number Systems Rayat Shikshan Sanstha’s
Chapter 2 Number Systems.
Number Systems Rayat Shikshan Sanstha’s
Number Systems Rayat Shikshan Sanstha’s
Chapter 2 Number Systems.
Scientific Notation.
GCSE COMPUTER SCIENCE Topic 3 - Data 3.4 Hexadecimal Conversion.
Number Systems Rayat Shikshan Sanstha’s
Chapter 2 Number Systems.
Computer Architecture CST 250
Chapter 2 Number Systems.
Presentation transcript:

Binary / Hex Binary and Hex The number systems of Computer Science

Main Memory Memory cells have two states: On Off Work best with two-state number system --- Binary number system Investigate Decimal number system first

The Decimal Numbering System The decimal number system is a positional number system: the same digit will have different values in different positions. Examples: 5 “five” = 5 * 1 50 “fifty” = 5 * 10 500 “five-hundred” = 5*100

The Decimal Numbering System Combinations yield any integer. Example: 5 6 2 1 1 X 100 1000 100 10 1 2 X 101 6 X 102 5 X 103

What is the base ? The decimal numbering system is also known as base 10. The values of the positions are calculated by taking 10 to some power. The common number system is a decimal or base 10 system because we use 10 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

(Can you feel the tension building?) What is the base ? The binary numbering system is called binary because it uses base 2. The values of the positions are calculated by taking 2 to some power. The Binary system uses just two digits: 0 and 1 A memory cell has just two states… (Can you feel the tension building?)

The Binary Numbering System The Binary Numbering System is also a positional numbering system. Instead of ten digits, 0 - 9, the binary system uses only two digits, 0 and 1. Example of a binary number & the values of the positions. 1 0 0 0 0 0 1 ( = 65) 26 25 24 23 22 21 20

Computing the Decimal Values of Binary Numbers 1 0 0 0 0 0 1 1 X 20 = 1 26 25 24 23 22 21 20 0 X 21 = 0 0 X 22 = 0 20 = 1 24 = 16 0 X 23 = 0 21 = 2 25 = 32 0 X 24 = 0 22 = 4 26 = 64 0 X 25 = 0 23 = 8 1 X 26 = 64 65

Converting Decimal to Binary First make a list of the values of 2 to the powers of 0 to 8, then use the subtraction method. 20 = 1, 21 = 2, 22 = 4, 23 = 8, 24 = 16, 25 = 32, 26 = 64, 27 = 128, 28 = 256 Example: 42 42 10 2 - 32 - 8 - 2 1 0 1 0 1 0 25 24 23 22 21 20

Counting in Binary Binary 1 10 11 100 101 110 111 Decimal equivalent 1 1 10 11 100 101 110 111 Decimal equivalent 1 2 3 4 5 7 8

Addition of Binary Numbers Examples: 1 0 0 1 0 0 0 1 1 1 0 0 + 0 1 1 0 + 1 0 0 1 + 0 1 0 1 1 1 1 1 1 0 1 0 1 0 0 0 1

Addition of Large Binary Numbers Example showing larger numbers: 1 0 1 0 0 0 1 1 1 0 1 1 0 0 0 1 + 0 1 1 1 0 1 0 0 0 0 0 1 1 0 0 1 1 0 0 0 1 0 1 1 1 1 1 0 0 1 0 1 0

Working with large numbers 0 1 0 1 0 0 0 0 1 0 0 1 0 1 1 1 Humans can’t work well with binary numbers. We will make errors. 110010111001101010 * 110010100101 Hexadecimal: Shorthand for binary

Hexadecimal Binary 0 1 0 1 0 0 0 0 1 0 0 1 0 1 1 1 Hex 5 0 9 7 Written: 509716

The Amazing Secret of Hexadecimal Notation! Binary 0 1 0 1 0 0 0 0 1 0 0 1 0 1 1 1 Hex 5 0 9 7 The amazing secret: 16 = 28

Hexadecimal Binary is base 2 two digits: 0, 1 Decimal is base 10 ten digits: 0, 1, 3, 4, 5, 6, 7, 8, 9. Hexadecimal (hex) is base 16. How many digits do we need to express numbers in hex? 16: 0 1 2 3 4 5 6 7 8 9 A B C D E F

Counting in Hex Binary Hex Binary Hex 0 0 0 0 0 1 0 0 0 8 0 0 0 0 0 1 0 0 0 8 0 0 0 1 1 1 0 0 1 9 0 0 1 0 2 1 0 1 0 A 0 0 1 1 3 1 0 1 1 B 0 1 0 0 4 1 1 0 0 C 0 1 0 1 5 1 1 0 1 D 0 1 1 0 6 1 1 1 0 E 0 1 1 1 7 1 1 1 1 F

Another Binary to Hex Conversion Hex 7 C 3 F 7C3F16

Storing Negative Numbers in Binary Since we need to store negative numbers as well as positive numbers in binary, special variations on binary are used. 2’s Complement notation is used for integers.

Building the 2’s Complement of a Binary Number Start with a binary number x = 1001 0101 Replace 1 by 0, replace each 0 by 1 x1 = 0110 1010 (“one’s complement”) Add 1 to the least significant digit x2 = 0110 1011 (“two’s complement”)

Why Two’s Complement? Adding the two’s complement of a number is like subtracting the number x+x2 = 1001 0101 + 0110 1011 1001 0101 0110 1011 (1) 0000 0000 where the leading 1 is in parentheses because it will be ignored. Replaces Subtraction by Addition

Review The decimal, binary, and hexadecimal number systems are positional systems The decimal number system has 10 digits, the binary system two, the hexadecimal system has 16 The binary system is good system to use for two state memory devices.

Review The hexadecimal system (“hex”) needs 16 digits, so it uses 0-9,A,B,C,D,E,F The hexadecimal system is a often a convenient shorthand for the binary system: 4-bits to one hex digit Negative numbers are stored using “two’s complement” which turns subtraction into addition.