EM108 Software Development for Engineers Section 5 Storing Information

Similar documents
Systems I: Computer Organization and Architecture

LSN 2 Number Systems. ECT 224 Digital Computer Fundamentals. Department of Engineering Technology

Binary Numbers. Binary Octal Hexadecimal

Useful Number Systems

Chapter 4: Computer Codes

The string of digits in the binary number system represents the quantity

2011, The McGraw-Hill Companies, Inc. Chapter 3

3. Convert a number from one number system to another

Section 1.4 Place Value Systems of Numeration in Other Bases

CSI 333 Lecture 1 Number Systems

Base Conversion written by Cathy Saxton

HOMEWORK # 2 SOLUTIO

Computer Science 281 Binary and Hexadecimal Review

Oct: 50 8 = 6 (r = 2) 6 8 = 0 (r = 6) Writing the remainders in reverse order we get: (50) 10 = (62) 8

Today s topics. Digital Computers. More on binary. Binary Digits (Bits)

2 Number Systems. Source: Foundations of Computer Science Cengage Learning. Objectives After studying this chapter, the student should be able to:

CDA 3200 Digital Systems. Instructor: Dr. Janusz Zalewski Developed by: Dr. Dahai Guo Spring 2012

Solution for Homework 2

Chapter Binary, Octal, Decimal, and Hexadecimal Calculations

Chapter 2. Binary Values and Number Systems

Lecture 11: Number Systems

Levent EREN A-306 Office Phone: INTRODUCTION TO DIGITAL LOGIC

EE 261 Introduction to Logic Circuits. Module #2 Number Systems

CS101 Lecture 11: Number Systems and Binary Numbers. Aaron Stevens 14 February 2011

Machine Architecture and Number Systems. Major Computer Components. Schematic Diagram of a Computer. The CPU. The Bus. Main Memory.

CPEN Digital Logic Design Binary Systems

plc numbers Encoded values; BCD and ASCII Error detection; parity, gray code and checksums

Numbering Systems. InThisAppendix...

Number Representation

Counting in base 10, 2 and 16

Lecture 2. Binary and Hexadecimal Numbers

Positional Numbering System

Binary Representation. Number Systems. Base 10, Base 2, Base 16. Positional Notation. Conversion of Any Base to Decimal.

Computers. Hardware. The Central Processing Unit (CPU) CMPT 125: Lecture 1: Understanding the Computer

Memory is implemented as an array of electronic switches

A single register, called the accumulator, stores the. operand before the operation, and stores the result. Add y # add y from memory to the acc

Digital Design. Assoc. Prof. Dr. Berna Örs Yalçın

Cyber Security Workshop Encryption Reference Manual

The use of binary codes to represent characters

COMPSCI 210. Binary Fractions. Agenda & Reading

NUMBER SYSTEMS. William Stallings

Number Conversions Dr. Sarita Agarwal (Acharya Narendra Dev College,University of Delhi)

2010/9/19. Binary number system. Binary numbers. Outline. Binary to decimal

Data Storage. 1s and 0s

Chapter 5. Binary, octal and hexadecimal numbers

Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T)

Binary Number System. 16. Binary Numbers. Base 10 digits: Base 2 digits: 0 1

This 3-digit ASCII string could also be calculated as n = (Data[2]-0x30) +10*((Data[1]-0x30)+10*(Data[0]-0x30));

1. Give the 16 bit signed (twos complement) representation of the following decimal numbers, and convert to hexadecimal:

Unsigned Conversions from Decimal or to Decimal and other Number Systems

Digital System Design Prof. D Roychoudhry Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

ASCII Code. Numerous codes were invented, including Émile Baudot's code (known as Baudot

1. Convert the following base 10 numbers into 8-bit 2 s complement notation 0, -1, -12

Binary Representation

Sheet 7 (Chapter 10)

Data Storage. Chapter 3. Objectives. 3-1 Data Types. Data Inside the Computer. After studying this chapter, students should be able to:

Chapter 7 Lab - Decimal, Binary, Octal, Hexadecimal Numbering Systems

Numeral Systems. The number twenty-five can be represented in many ways: Decimal system (base 10): 25 Roman numerals:

Pemrograman Dasar. Basic Elements Of Java

=

Third Southern African Regional ACM Collegiate Programming Competition. Sponsored by IBM. Problem Set

The Hexadecimal Number System and Memory Addressing

The New IoT Standard: Any App for Any Device Using Any Data Format. Mike Weiner Product Manager, Omega DevCloud KORE Telematics

Data Storage 3.1. Foundations of Computer Science Cengage Learning

Everything you wanted to know about using Hexadecimal and Octal Numbers in Visual Basic 6

PROBLEMS (Cap. 4 - Istruzioni macchina)

Digital codes. Resources and methods for learning about these subjects (list a few here, in preparation for your research):

Divide: Paper & Pencil. Computer Architecture ALU Design : Division and Floating Point. Divide algorithm. DIVIDE HARDWARE Version 1

Chapter 1. Binary, octal and hexadecimal numbers

The programming language C. sws1 1

Upon completion of unit 1.1, students will be able to

Goals. Unary Numbers. Decimal Numbers. 3,148 is s 100 s 10 s 1 s. Number Bases 1/12/2009. COMP370 Intro to Computer Architecture 1

Copyright 2012 Pearson Education, Inc. Chapter 1 INTRODUCTION TO COMPUTING AND ENGINEERING PROBLEM SOLVING

As previously noted, a byte can contain a numeric value in the range Computers don't understand Latin, Cyrillic, Hindi, Arabic character sets!

Chapter 1: Digital Systems and Binary Numbers

COMP 250 Fall 2012 lecture 2 binary representations Sept. 11, 2012

CS201: Architecture and Assembly Language

Binary Adders: Half Adders and Full Adders

How to represent characters?

NUMBER SYSTEMS. 1.1 Introduction

Package PKI. February 20, 2013

The Answer to the 14 Most Frequently Asked Modbus Questions

I PUC - Computer Science. Practical s Syllabus. Contents

Technical Information. Digital Signals. 1 bit. Part 1 Fundamentals

To convert an arbitrary power of 2 into its English equivalent, remember the rules of exponential arithmetic:

Digital Logic Design. Introduction

PROGRAMMING IN C PROGRAMMING IN C CONTENT AT A GLANCE

Number Systems and Radix Conversion

CS321. Introduction to Numerical Methods

Binary, Hexadecimal, Octal, and BCD Numbers

HP Business Notebook Password Localization Guidelines V1.0

Session 29 Scientific Notation and Laws of Exponents. If you have ever taken a Chemistry class, you may have encountered the following numbers:

ASSEMBLY LANGUAGE PROGRAMMING (6800) (R. Horvath, Introduction to Microprocessors, Chapter 6)

Technical Support Bulletin Nr.18 Modbus Tips

A Step towards an Easy Interconversion of Various Number Systems

Today. Binary addition Representing negative numbers. Andrew H. Fagg: Embedded Real- Time Systems: Binary Arithmetic

Tokens and Python s Lexical Structure

Decimal Number (base 10) Binary Number (base 2)

Number of bits needed to address hosts 8

Transcription:

EM108 5 Storing Information page 1 of 11 EM108 Software Development for Engineers Section 5 Storing Information 5.1 Motivation: Various information types o Various types of numbers o Text o Images, Audios, Videos Storage and processing by computers o Ease of representation within computer memory/storage o Simplicity of data processing o Minimum effort of conversion between real world format and internal computer representation and vice-versa 5.2 Solution: Binary representation o Any data is converted into and from binary when inputted and outputted respectively o Internally all processing is performed in binary format

EM108 5 Storing Information page 2 of 11 5.3 Binary number system: Binary to decimal conversion Rank: 4 3 2 1 0 No: 1 0 0 1 1 2 10011 2 = 1 * 2 0 + 1 * 2 1 + 0 * 2 2 + 0 * 2 3 + 1 * 2 4 = = 1 * 1 + 1 * 2 + 0 * 4 + 0 * 8 + 1 * 16 = = 19 10 Decimal to binary conversion Decimal Base Binary No. Divisor Quotient Remnant 19 2 9 1 9 2 4 1 4 2 2 0 2 2 1 0 1 2 0 1 19 10 = 10011 2

EM108 5 Storing Information page 3 of 11 Notes about number systems o Decimal system (base 10) is based on powers of 10 o It has 10 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 43 10 = 4 * 10 1 + 3 * 10 0 = 40 + 3 957 10 = 9 * 10 2 + 5 * 10 1 + 7 * 10 0 = 900 + 50 + 7 o Binary system (base 2) is based on powers of 2 o It has 2 digits: 0 and 1 110 2 = 1 * 2 2 + 1 * 2 1 + 0 * 2 0 = 4 + 2 + 0 = 6 10 101 2 = 1 * 2 2 + 0 * 2 1 + 1 * 2 0 = 4 + 0 + 1 = 5 10 o Octal system (base 8) is based on powers of 8 o It has 8 digits: 0, 1, 2, 3, 4, 5, 6, 7 123 8 = 1 * 8 2 + 2 * 8 1 + 3 * 8 0 = 64 + 16 + 3 = 83 10 47 8 = 4 * 8 1 + 7 * 8 0 = 32 + 7 = 39 10 o Hexadecimal system (base 16) is based on powers of 16 o It has 16 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F B3 16 = B * 16 1 + 3 * 16 0 = 11 * 16 + 3 * 1 = 179 10 47 16 = 4 * 16 1 + 7 * 16 0 = 4 * 16 + 7 * 1 = 71 10

EM108 5 Storing Information page 4 of 11 Correspondence Table Decimal Binary Octal Hexadecimal 0 0 0 0 1 1 1 1 2 10 2 2 3 11 3 3 4 100 4 4 5 101 5 5 6 110 6 6 7 111 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 16 10000 20 10

EM108 5 Storing Information page 5 of 11 Hexadecimal to binary conversion o Each hexadecimal digit corresponds to a four digit binary number o Replace each hexadecimal digit with corresponding four digit binary number Hexadecimal A 3 E 9 3 16 Binary 1010 0011 1110 1001 0011 2 Binary to hexadecimal conversion o Each group of four binary digits (a binary four digit number) corresponds to one hexadecimal digit o Group binary digits in clusters of four, starting from right o Add leading 0-s in front of the binary number if necessary o Replace each four digit binary group with the corresponding hexadecimal digit Binary 0010 0101 1011 1000 0001 2 Hexadecimal 2 5 B 8 1 16 Homework o Octal to binary conversion o Binary to octal conversion o Practice conversions as much as you can

EM108 5 Storing Information page 6 of 11 5.4 Definitions: Bit Byte o Single binary digit (1 or 0) o A set of 8 adjacent bits Least Significant Bit o Right most bit in a byte Most Significant Bit o Left most bit in a byte 5.5 Binary operations: Arithmetic o Based on the following tables X+Y Y=0 Y=1 X-Y Y=0 Y=1 X=0 0 1 X=0 0-1 X=1 1 10 X=1 1 0 X*Y Y=0 Y=1 X/Y Y=0 Y=1 X=0 0 0 X=0-0 X=1 0 1 X=1-1

EM108 5 Storing Information page 7 of 11 Logic o Based on the following tables X or Y Y=0 Y=1 X and Y Y=0 Y=1 X=0 0 1 X=0 0 0 X=1 1 1 X=1 0 1 X xor Y Y=0 Y=1 not X X=0 0 1 X=0 1 X=1 1 0 X=1 0 E.g. X 1 0 0 0 1 1 0 1 0 1 0 0 0 1 1 0 Y 1 1 1 1 0 1 1 0 0 1 1 0 1 X + Y 1 0 1 0 1 1 0 0 0 0 0 1 0 0 1 1 Hex A C 1 3 X 1 0 0 0 1 1 0 1 0 1 0 0 0 1 1 0 Y 1 1 1 1 0 1 1 0 0 1 1 0 1 X or Y 1 0 0 1 1 1 1 1 1 1 0 0 1 1 1 1 Hex 9 F C F

EM108 5 Storing Information page 8 of 11 5.6 Representing Various Numbers: Positive Integers o Binary representation o In 16-bit or 32-bit long locations of memory o Leading 0-s are added in front o Hexadecimal is used for easiness of notation Decimal 1 9 Binary 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 1 Hexadecimal 0 0 1 3 Sign Integers o Binary representation + a sign bit in the most significant location o In 16-bit or 32-bit long locations of memory o Leading 0-s (for positive numbers) or 1-s (for negative numbers) are added in front o Hexadecimal is used for easiness of notation Decimal - 1 9 Binary 1 1 1 1 1 1 1 1 1 1 1 1 0 0 1 1 Hexadecimal F F F 3

EM108 5 Storing Information page 9 of 11 Real Numbers o Binary representation (in mantissa + exponent format) + a sign bit in the most significant location o In 32-bit or 64-bit long locations of memory o Leading 0-s (for positive numbers) or 1-s (for negative numbers) are added in front o Hexadecimal is used for easiness of notation o E.g. 5,000,000 10 0.5 * 10 7 o E.g. -0.00053 10-0.53 * 10-3 o E.g. 1234.456 10 0.1234456 * 10 4 MANTISSA EXPONENT 5.7 Representing Text: Characters o General term used for letters, digits and punctuation o Each character is assigned a unique numerical code o How many codes are needed? o Digits (10): 0, 1, 2, 3,, 9 o Lower case letters (26): a, b, c,, z o Upper case letters (26): A, B, C,, Z o Punctuation (16):., ; :?! ` { } [ ] ( ) o Special characters (18): # $ % ^ & * + - = \ / < > ~ o Other characters: ± ¼ פּΩ o Characters for other languages: ß â ç ê ţ Њ љ

EM108 5 Storing Information page 10 of 11 ASCII code o 7 bits allocated to store each code o 2 7 = 128 codes for 128 possible characters o Covers digits, lower and upper case letters, punctuation, special and other characters o Does not cover characters for other languages (accents, umlauts, fadas) Latin-1 o Specified by the International standards Organization (ISO) o A subset of ISO-8859 that includes several sets of characters for writing in Cyrillic, Arabic, Hebrew, etc. o Extends ASCII, including additional characters used in some West European languages such as Irish, French and German o One byte (8 bits) allocated to store each code o 2 8 = 256 codes for 256 possible characters o Text encoded in Latin-1 can be transmitted through e-mail and be printed on any computer system, being accepted as basis for every text file formats o E.g. a <=> 97 10 = 1100001 2 = 61 16 Decimal 9 7 Binary 0 1 1 0 0 0 0 1 Hexadecimal 6 1

EM108 5 Storing Information page 11 of 11 Words (Strings) o A word is represented as a sequence of 0 or more characters in form of a string or an array of characters o E.g. ee108 = [ e, e, 1, 0, 8 ] = [101, 101, 49, 48, 56] Binary 0 1 1 0 0 1 0 1 Hexa 6 3 Binary 0 1 1 0 0 1 0 1 Hexa 6 3 Binary 0 0 1 1 0 0 0 1 Hexa 3 1 Binary 0 0 1 1 0 0 0 0 Hexa 3 0 Binary 0 0 1 1 1 0 0 0 Hexa 3 8