Bits. Binary Digits. 0 or 1

Similar documents
CS & IT Conversions. Magnitude 10,000 1,

The. Binary. Number System

Objectives. Connecting with Computer Science 2

Lecture (01) Digital Systems and Binary Numbers By: Dr. Ahmed ElShafee

Positional notation Ch Conversions between Decimal and Binary. /continued. Binary to Decimal

Lecture (01) Introduction Number Systems and Conversion (1)

Number representations

Octal & Hexadecimal Number Systems. Digital Electronics

MACHINE LEVEL REPRESENTATION OF DATA

Conversion Between Number Bases

Data Types. Numeric Data Types

TOPICS. Other Number Systems. Other Number Systems 9/9/2017. Octal Hexadecimal Number conversion

Intermediate Programming & Design (C++) Notation

What Is It? Instruction Register Address Register Data Register

Numeral Systems. -Numeral System -Positional systems -Decimal -Binary -Octal. Subjects:

Beyond Base 10: Non-decimal Based Number Systems

CHAPTER 2 Number Systems

Chapter 1 Preliminaries

2 Number Systems 2.1. Foundations of Computer Science Cengage Learning

NUMERIC SYSTEMS USED IN NETWORKING

Information Science 1

Number System. Introduction. Decimal Numbers

Chapter 3 DATA REPRESENTATION

Chapter 1 Emad Felemban

1.3 Systems of numeration: To represent quantities in the different systems of numeration, specific symbols are used, which are also called ciphers.

1.1. INTRODUCTION 1.2. NUMBER SYSTEMS

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University.

CMPS 10 Introduction to Computer Science Lecture Notes

Chapter 2 Binary Values and Number Systems

Digital Fundamentals

Beyond Base 10: Non-decimal Based Number Systems

COE 202- Digital Logic. Number Systems II. Dr. Abdulaziz Y. Barnawi COE Department KFUPM. January 23, Abdulaziz Barnawi. COE 202 Logic Design

umber Systems bit nibble byte word binary decimal

Moodle WILLINGDON COLLEGE SANGLI. ELECTRONICS (B. Sc.-I) Introduction to Number System

Final Labs and Tutors

Number Systems MA1S1. Tristan McLoughlin. November 27, 2013

Introduction to Computer Science-103. Midterm

Exercise: Using Numbers

Digital Systems COE 202. Digital Logic Design. Dr. Muhamed Mudawar King Fahd University of Petroleum and Minerals

Electronic Data and Instructions

Number Systems. TA: Mamun. References: Lecture notes of Introduction to Information Technologies (ITEC 1011) by Dr Scott MacKenzie

Introduction to Numbering Systems

The type of all data used in a C (or C++) program must be specified

Variables, Constants, and Data Types

The type of all data used in a C++ program must be specified

DATA REPRESENTATION. By- Neha Tyagi PGT CS KV 5 Jaipur II Shift, Jaipur Region. Based on CBSE curriculum Class 11. Neha Tyagi, KV 5 Jaipur II Shift

Digital Logic. The Binary System is a way of writing numbers using only the digits 0 and 1. This is the method used by the (digital) computer.

Memory Addressing, Binary, and Hexadecimal Review

Level ISA3: Information Representation

Data Representation COE 301. Computer Organization Prof. Muhamed Mudawar

Number Systems and Binary Arithmetic. Quantitative Analysis II Professor Bob Orr

Number Systems and Conversions UNIT 1 NUMBER SYSTEMS & CONVERSIONS. Number Systems (2/2) Number Systems (1/2) Iris Hui-Ru Jiang Spring 2010

Number Systems CHAPTER Positional Number Systems


Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 1: Basic Concepts. Chapter Overview. Welcome to Assembly Language

Digital Logic Lecture 2 Number Systems

CMPE223/CMSE222 Digital Logic Design. Positional representation

CHAPTER 2 - DIGITAL DATA REPRESENTATION AND NUMBERING SYSTEMS

CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 01, SPRING 2013

Number Systems Using and Converting Between Decimal, Binary, Octal and Hexadecimal Number Systems

History of Computing. Ahmed Sallam 11/28/2014 1

Computer Science 1000: Part #3. Binary Numbers

Binary, Hexadecimal and Octal number system

THE LOGIC OF COMPOUND STATEMENTS

Experimental Methods I

ECOM 2325 Computer Organization and Assembly Language. Instructor: Ruba A.Salamah INTRODUCTION

ITEC 1011 Introduction to Information Technologies

Lecture 1: Digital Systems and Number Systems

Chapter 1 Review of Number Systems

CHW 261: Logic Design

The Design of C: A Rational Reconstruction

Octal and Hexadecimal Integers

The Design of C: A Rational Reconstruction"

Introduction to Computers and Programming. Numeric Values

Number System (Different Ways To Say How Many) Fall 2016

Beginning C Programming for Engineers

Logic Circuits I ECE 1411 Thursday 4:45pm-7:20pm. Nathan Pihlstrom.

Chapter 3: Number Systems and Codes. Textbook: Petruzella, Frank D., Programmable Logic Controllers. McGraw Hill Companies Inc.

Digital Systems and Binary Numbers

MATH 104B OCTAL, BINARY, AND HEXADECIMALS NUMBERS

Fundamentals of Programming (C)

COMP Overview of Tutorial #2

Binary. Hexadecimal BINARY CODED DECIMAL

Course Schedule. CS 221 Computer Architecture. Week 3: Plan. I. Hexadecimals and Character Representations. Hexadecimal Representation

Module 1: Information Representation I -- Number Systems

Data Representation. Interpreting bits to give them meaning. Part 1: Numbers, Bases, and Binary

Common Number Systems

Fundamentals of Programming

BINARY SYSTEM. Binary system is used in digital systems because it is:

Number codes nibble byte word double word

Number Systems. Dr. Tarek A. Tutunji Philadelphia University, Jordan

Chapter Overview. Assembly Language for Intel-Based Computers, 4 th Edition. Chapter 1: Basic Concepts. Printing this Slide Show

Chapter 2 Exercises and Answers

Hexadecimal Numbers. Journal: If you were to extend our numbering system to more digits, what digits would you use? Why those?

Bits, bytes, binary numbers, and the representation of information

Visual C# Instructor s Manual Table of Contents

Korea University of Technology and Education

COE 202: Digital Logic Design Number Systems Part 2. Dr. Ahmad Almulhem ahmadsm AT kfupm Phone: Office:

The Design of C: A Rational Reconstruction

TOPIC: NUMBER SYSTEMS

Transcription:

Data Representation

Bits Binary Digits 0 or 1 Everything stored in a computer is stored as bits. Bits can mean different things depending on how the software or hardware interpret the bits Bits are usually grouped into chunks of eight bits A chuck of eight bits is called a byte

Digitization Convertor 01100110 Computing Device 0011010 Convertor Input such as sound, light, pressing a key Output such as sound, light, moving a robot arm

Bits Consider the follow byte ( 8 bits) 01011010 What could it represent? The integer 90 The letter Z (ASCII) Red part of color deep reddish brown http://www.perbang.dk/rgb/5a0000/ The opcode of an instruction The sequence of boolean values false true false true true false true false

Common Questions How many bits are needed to represent a set of values? How many bits do I need to represent the values in a set with N elements? Ceiling(log 2 N) If N is 8 then 3 bits are required If N is 11 then 4 bits are required

Common Questions How many values can be represented with a given number of bits? How many values can be represented with N bits? 2 N If N is 5 the 32 values can be represented If N is 7 then 128 values can be represented

Maximum Patterns for a Given Number of Bits Number of Bits Maximum Number of Pattern 1 2 2 4 3 8 4 16 8 256 N 2 N

Counting In Binary Binary Decimal 0 0 1 1 10 2 11 3 100 4 101 5 110 6 111 7 1000 8 1001 9 1010 10 1011 11

Character Code Mapping between numbers and characters ASCII Unicode

ASCII Codes Letter Symbol, Decimal, Binary A, 65, 01000001 B, 66, 01000010 C, 67, 01000011 D, 68, 01000100 E, 69, 01000101 F, 70, 01000110 G, 71, 01000111 H, 72, 01001000 I, 73, 01001001 Symbol, Decimal, Binary a, 97, 01100001 b, 98, 01100010 c, 99, 01100011 d, 100, 01100100 e, 101, 01100101 f, 102, 01100110 g,103, 01100111 h,104, 01101000 i, 105, 01101001

ASCII Codes Digits and Other Symbol, Decimal, Binary 0, 48, 00110000 1, 49, 00110001 2, 50, 00110010 3, 51, 00110011 4, 52, 00110100 5, 53, 00110101 6, 54, 00110110 7, 55, 00110111 8, 56, 00111000 9, 57, 00111001 Symbol, Decimal, Binary Line Feed, 10, 00001010 Space, 32, 00100000

ASCII Character Code

ASCII Character Code

Example Problem Convert the word Computer into a sequence of numbers representing the ASCII characters codes of the letters.

Example Problem Answer Computer 67 111 109 112 117 116 101 114

Example Problem Convert the following sequence of numbers to text using the ASCII character code. To make the sequence easier to read a space is used to separate numbers. 67 111 100 101 33

Example Problem Answer 67 111 100 101 33 Code!

Practice Problems Convert the sequence of letters in your name (first last) into a sequence of numbers using the ASCII character code. The code for a space is 32 Convert the following sequence of numbers to text using the ASCII character code. To make the sequence easier to read a space is used to separate numbers. 87 104 97 116 32 102 117 110 33

Place-Value Notation Consider the base 10 number 7438 This number (sequence of digits) represents 7*10 3 + 4*10 2 + 3*10 1 + 8*10 0 7000+400+30+8 = 7438 Since the number is a base 10 number the digit in position i is multiplied by 10 i Positions are numbered from right to left beginning at 0 This works for any base A base n number must have n different digits

Place-Valued Notation Most common bases used in computer science Base 2 (binary) Base 8 (octal) Base 10 (decimal) Base 16 (Hexadecimal)

Base 2 Two Digits 0 and 1 Consider the base 2 number 100111 This number represents 1*2 5 + 0*2 4 + 0*2 3 + 1*2 2 + 1*2 1 + 1*2 0 Since there are only two digits it is common to write the above expression using only the powers of 2 that are multiplied by 1 2 5 + 2 2 + 2 1 + 2 0 This represents to base 10 number 32 + 4 + 2 + 1 = 39 To indicate the base of a number a subscript is sometimes used at the end of the number 100111 2

Powers of 2 Formula Value 2 0 1 2 1 2 2 2 4 2 3 8 2 4 16 2 5 32 2 6 64 2 7 128 2 8 256 2 9 512 2 10 1024

Base 8 Eight digits 0, 1, 2, 3, 4, 5, 6, 7 Consider the base 8 number 5072 The number represents 5 * 8 3 + 0 * 8 2 + 7*8 1 + 2*8 0 The is equivalent to the base 10 number 5 * 512 + 0 * 64 + 7 * 8 + 2 * 1 = 2618

Powers of 8 Formula Value 8 0 1 8 1 8 8 2 64 8 3 512 8 4 4096 8 5 32768 8 6 262144 8 7 2097152

Base 16 Sixteen digits Consider the base 16 number B74D This number represents B*16 3 + 7*16 2 + 4*16 1 + D*16 0 11*16 3 + 7*16 2 + 4*16 1 + 13*16 0 This is equivalent to the base 10 number 11*4096 + 7*256 + 4*16 + 13*1 = 46925

Powers of 16 Formula Value 16 0 1 16 1 16 16 2 256 16 3 4096 16 4 65536 16 5 1048576

Base 10 Base 2 Base 8 Base 16 0 0000 0 0 1 0001 1 1 2 0010 2 2 3 0011 3 3 4 0100 4 4 5 0101 5 5 6 0110 6 6 7 0111 7 7 8 1000 10 8 9 1001 11 9 10 1010 12 A 11 1011 13 B 12 1100 14 C 13 1101 15 D 14 1110 16 E 15 1111 17 F

Conversion Problems Convert between bases For example given the base 2 number 11001001 find the equivalent base 10 and base 16 number Base 10 201 Base 16 C9

Conversion Problems Base 2 -> Base 10 Base 2 -> Base 16 Base 10 -> Base 2 Base 10 -> Base 16 Base 16 -> Base 2 Base 16 -> Base 10

Convert Base 2 to Base 16 last4bits(x) last4bits(11001101) 1101 bitsexcludinglast4(x) bitsexcludinglast4(11001101) 1100

Convert base 2 to base 16 concatenate(a, B) concatenate(6, 547) 6547 base16digit(x) base16digit(1100) C

Algorithm to Convert Base 2 to Base 16 Let X be the base 2 number we want to convert to base 16 Give B the value of the empty string Do the following Give Y the value of last4bits(x) Give Z the value base16digit(y) Give B the value concatenate(z, B) Given X the value of bitsexcludinglast4(x) Until X is empty B is the base 16 representation of the original X

Algorithm to convert base 10 representation to binary representation Let X be the base 10 representation to convert Give B the value of the empty string Do the following Give Y the value of the integer quotient of X / 2 Give Z the value of the remainder of X / 2 Give B the value of concatenate(z, B) Give X the value of Y Until X is 0 B is now the binary representation of the original value of X

Example: convert 14 10 to binary X Y Z B 14 7 0 7 0 3 1 3 10 1 1 1 110 0 1 0 1110

Practice Problems Convert the following base 10 numbers to base 2 27 43 80 How can you check your answer?

How Many Dots? 10101 2 25 8 21 10 15 16