# Number Representation

Save this PDF as:

Size: px
Start display at page:

Download "Number Representation"

## Transcription

1 Number Representation

2 Number System :: The Basics We are accustomed to using the so-called decimal number system Ten digits ::,,,3,4,5,6,7,8,9 Every digit position has a weight which is a power of Base or radix is Example: 34 = x + 3 x + 4 x 5.67 = x + 5 x + x + 6 x x -

3 Binary Number System Two digits: and Every digit position has a weight which is a power of Base or radix is Example: = x + x + x. = x + x + x + x - + x - 3

4 Positional Number Systems (General) Decimal Numbers: Symbols {,,,3,4,5,6,7,8,9}, Base or Radix is 36.5 =

5 Positional Number Systems (General) Decimal Numbers: Symbols {,,,3,4,5,6,7,8,9}, Base or Radix is 36.5 = Binary Numbers: Symbols {,}, Base or Radix is. =

6 Positional Number Systems (General) Decimal Numbers: Symbols {,,,3,4,5,6,7,8,9}, Base or Radix is 36.5 = Binary Numbers: Symbols {,}, Base or Radix is. = Octal Numbers: 8 Symbols {,,,3,4,5,6,7}, Base or Radix is =

7 Positional Number Systems (General) Decimal Numbers: Symbols {,,,3,4,5,6,7,8,9}, Base or Radix is 36.5 = Binary Numbers: Symbols {,}, Base or Radix is. = Octal Numbers: 8 Symbols {,,,3,4,5,6,7}, Base or Radix is = Hexadecimal Numbers: 6 Symbols {,,,3,4,5,6,7,8,9,A,B,C,D,E,F}, Base is 6 6AF.3C =

8 Binary-to-Decimal Conversion Each digit position of a binary number has a weight Some power of A binary number: B = b n- b n-..b b. b - b -.. b -m Corresponding value in decimal: n- D = Σ i = -m b i i 8

9 Examples x 5 + x 4 + x 3 + x + x + x = 43 () = (43). x - + x - + x -3 + x -4 =.35 (.) = (.35). x + x + x + x - + x - = 5.75 (.) = (5.75) 9

10 Decimal to Binary: Integer Part Consider the integer and fractional parts separately. For the integer part: Repeatedly divide the given number by, and go on accumulating the remainders, until the number becomes zero. Arrange the remainders in reverse order. Base NumbRem (89) = ()

11 Decimal to Binary: Integer Part Consider the integer and fractional parts separately. For the integer part: Repeatedly divide the given number by, and go on accumulating the remainders, until the number becomes zero. Arrange the remainders in reverse order. Base NumbRem (89) = () (66) = ()

12 Decimal to Binary: Integer Part Consider the integer and fractional parts separately. For the integer part: Repeatedly divide the given number by, and go on accumulating the remainders, until the number becomes zero. Arrange the remainders in reverse order. Base NumbRem (89) = () (66) = () (39) = ()

13 Decimal to Binary: Fraction Part Repeatedly multiply the given fraction by. Accumulate the integer part ( or ). If the integer part is, chop it off. Arrange the integer parts in the order they are obtained. Example: x = x = x =.7.7 x = x =.88 : : (.634) = (. ) 3

14 Decimal to Binary: Fraction Part Repeatedly multiply the given fraction by. Accumulate the integer part ( or ). If the integer part is, chop it off. Arrange the integer parts in the order they are obtained. Example: x = x = x =.7.7 x = x =.88 : : Example: x =.5.5 x =.5.5 x =.5.5 x =. (.65) = (.) (.634) = (. ) 4

15 Decimal to Binary: Fraction Part Repeatedly multiply the given fraction by. Accumulate the integer part ( or ). If the integer part is, chop it off. Arrange the integer parts in the order they are obtained. Example: x = x = x =.7.7 x = x =.88 : : (.634) = (. ) Example: x =.5.5 x =.5.5 x =.5.5 x =. (.65) = (.) (37) = () (.65) = (.) (37.65) = (.) 5

16 Hexadecimal Number System A compact way of representing binary numbers 6 different symbols (radix = 6) 8 9 A 3 B 4 C 5 D 6 E 7 F 6

17 Binary-to-Hexadecimal Conversion For the integer part, Scan the binary number from right to left Translate each group of four bits into the corresponding hexadecimal digit Add leading zeros if necessary For the fractional part, Scan the binary number from left to right Translate each group of four bits into the corresponding hexadecimal digit Add trailing zeros if necessary 7

18 Example. ( ) = (B43) 6. ( ) = (A) 6 3. (. ) = (.84) 6 4. (. ) = (5.5E) 6 8

19 Hexadecimal-to-Binary Conversion Translate every hexadecimal digit into its 4-bit binary equivalent Examples: (3A5) 6 = ( ) (.3D) 6 = (. ) (.8) 6 = (. ) 9

20 Unsigned Binary Numbers An n-bit binary number B = b n- b n-. b b b n distinct combinations are possible, to n -. For example, for n = 3, there are 8 distinct combinations,,,,,,, Range of numbers that can be represented n=8 to 8 - (55) n=6 to 6 - (65535) n=3 to 3 - ( )

21 Signed Integer Representation Many of the numerical data items that are used in a program are signed (positive or negative) Question:: How to represent sign? Three possible approaches: Sign-magnitude representation One s complement representation Two s complement representation

22 Sign-magnitude Representation For an n-bit number representation The most significant bit (MSB) indicates sign positive negative The remaining n- bits represent magnitude b n- b n- b b Sign Magnitude

23 Contd. Range of numbers that can be represented: Maximum :: + ( n- ) Minimum :: ( n- ) A problem: Two different representations of zero

24 One s Complement Representation Basic idea: Positive numbers are represented exactly as in sign-magnitude form Negative numbers are represented in s complement form How to compute the s complement of a number? Complement every bit of the number ( and ) MSB will indicate the sign of the number positive negative 4

25 Example :: n= To find the representation of, say, -4, first note that +4 = -4 = s complement of = 5

26 Contd. Range of numbers that can be represented: Maximum :: + ( n- ) Minimum :: ( n- ) A problem: Two different representations of zero Advantage of s complement representation Subtraction can be done using addition Leads to substantial saving in circuitry 6

27 Two s Complement Representation Basic idea: Positive numbers are represented exactly as in sign-magnitude form Negative numbers are represented in s complement form How to compute the s complement of a number? Complement every bit of the number ( and ), and then add one to the resulting number MSB will indicate the sign of the number positive negative 7

28 Example : n= To find the representation of, say, -4, first note that +4 = -4 = s complement of = + = Rule : Value = msb* (n ) + [unsigned value of rest] Example: = + 6 = 6 = = 8

29 Contd. Range of numbers that can be represented: Maximum :: + ( n- ) Minimum :: n- Advantage: Unique representation of zero Subtraction can be done using addition Leads to substantial saving in circuitry Almost all computers today use the s complement representation for storing negative numbers 9

30 Contd. In C short int 6 bits + ( 5 -) to - 5 int or long int 3 bits + ( 3 -) to - 3 long long int 64 bits + ( 63 -) to

31 Adding Binary Numbers Basic Rules: += += += += (carry ) Example:

32 Subtraction Using Addition :: s Complement How to compute A B? Compute the s complement of B (say, B ). Compute R = A + B If the carry obtained after addition is Add the carry back to R (called end-around carry) That is, R = R + The result is a positive number Else The result is negative, and is in s complement form 3

33 Example :: 6 s complement of = 6 :: A - :: B R +4 Assume 4-bit representations Since there is a carry, it is added back to the result The result is positive End-around carry 33

34 Example :: 3 5 s complement of 5 = 3 :: -5 :: - A B R Assume 4-bit representations Since there is no carry, the result is negative is the s complement of, that is, it represents 34

35 Subtraction Using Addition :: s Complement How to compute A B? Compute the s complement of B (say, B ) Compute R = A + B If the carry obtained after addition is Ignore the carry The result is a positive number Else The result is negative, and is in s complement form 35

36 Example :: 6 s complement of = + = 6 :: - :: A B R Assume 4-bit representations Presence of carry indicates that the result is positive Ignore carry +4 No need to add the endaround carry like in s complement 36

37 Example :: 3 5 s complement of 5 = + = 3 :: -5 :: - A B R Assume 4-bit representations Since there is no carry, the result is negative is the s complement of, that is, it represents 37

38 s complement arithmetic: More Examples Example : 8- =? 8 is represented as is represented as s complement of is s complement of is Add 8 to s complement of (with a carry of which is ignored) is 7 38

39 Example : 7-9 =? 7 is represented as 9 is represented as s complement of 9 is s complement of 9 is Add 7 to s complement of (with a carry of which is ignored) is - 39

40 Overflow/Underflow: Adding two +ve (-ve) numbers should not produce a ve (+ve) number. If it does, overflow (underflow) occurs 4

41 Overflow/Underflow: Adding two +ve (-ve) numbers should not produce a ve (+ve) number. If it does, overflow (underflow) occurs Another equivalent condition : carry in and carry out from Most Significant Bit (MSB) differ. 4

42 Overflow/Underflow: Adding two +ve (-ve) numbers should not produce a ve (+ve) number. If it does, overflow (underflow) occurs Another equivalent condition : carry in and carry out from Most Significant Bit (MSB) differ. (64) ( 4) (68) carry (out)(in) 4

43 Overflow/Underflow: Adding two +ve (-ve) numbers should not produce a ve (+ve) number. If it does, overflow (underflow) occurs Another equivalent condition : carry in and carry out from Most Significant Bit (MSB) differ. (64) ( 4) (68) (64) (96) (-96) carry (out)(in) carry out in differ: overflow 43

44 Floating-point Numbers The representations discussed so far applies only to integers Cannot represent numbers with fractional parts We can assume a decimal point before a signed number In that case, pure fractions (without integer parts) can be represented We can also assume the decimal point somewhere in between This lacks flexibility Very large and very small numbers cannot be represented 44

45 Representation of Floating-Point Numbers A floating-point number F is represented by a doublet <M,E> : F = M x B E B exponent base (usually ) M mantissa E exponent M is usually represented in s complement form, with an implied binary point before it For example, In decimal,.35 x 6 In binary,. x 45

46 Example :: 3-bit representation M E 4 8 M represents a s complement fraction > M > - E represents the exponent (in s complement form) 7 > E > -8 Points to note: The number of significant digits depends on the number of bits in M 6 significant digits for 4-bit mantissa The range of the number depends on the number of bits in E 38 to -38 for 8-bit exponent. 46

47 A Warning The representation for floating-point numbers as shown is just for illustration The actual representation is a little more complex Example: IEEE 754 Floating Point format 47

48 IEEE 754 Floating-Point Format (Single Precision) S (3) E (Exponent) (3 3) M (Mantissa) ( ) S: Sign ( is +ve, is ve) E: Exponent (More bits gives a higher range) M: Mantissa (More bits means higher precision) [8 bytes are used for double precision] Value of a Normal Number: (-) S (. +.M) (E 7) 48

49 An example S (3) E (Exponent) (3 3) M (Mantissa) ( ) Value of a Normal Number: = (-) S (. +.M) (E 7) = (-) (. +.) ( ) =. = = 54. ( in decimal) 49

50 Representing.3 S (3) E (Exponent) (3 3) M (Mantissa) ( ).3 (decimal) =. =. =. = (-) S (. +.M) (E 7) 5 7 What are the largest and smallest numbers that can be represented in this scheme? 5

51 Representing S (3) E (Exponent) (3 3) M (Mantissa) ( ) Representing Inf ( ) Representing NaN (Not a Number) Non zero Non zero 5

52 Representation of Characters Many applications have to deal with non-numerical data. Characters and strings There must be a standard mechanism to represent alphanumeric and other characters in memory Three standards in use: Extended Binary Coded Decimal Interchange Code (EBCDIC) Used in older IBM machines American Standard Code for Information Interchange (ASCII) Most widely used today UNICODE Used to represent all international characters. Used by Java 5

53 ASCII Code Each individual character is numerically encoded into a unique 7-bit binary code A total of 7 or 8 different characters A character is normally encoded in a byte (8 bits), with the MSB not been used. The binary encoding of the characters follow a regular ordering Digits are ordered consecutively in their proper numerical sequence ( to 9) Letters (uppercase and lowercase) are arranged consecutively in their proper alphabetic order 53

54 Some Common ASCII Codes A :: 4 (H) 65 (D) B :: 4 (H) 66 (D).. Z :: 5A (H) 9 (D) :: 3 (H) 48 (D) :: 3 (H) 49 (D).. 9 :: 39 (H) 57 (D) a :: 6 (H) 97 (D) b :: 6 (H) 98 (D).. z :: 7A (H) (D) ( :: 8 (H) 4 (D) + :: B (H) 43 (D)? :: 3F (H) 63 (D) \n :: A (H) (D) \ :: (H) (D) 54

55 Character Strings Two ways of representing a sequence of characters in memory 5 H e l l o The first location contains the number of characters in the string, followed by the actual characters H e l l o The characters follow one another, and is terminated by a special delimiter 55

56 String Representation in C In C, the second approach is used The \ character is used as the string delimiter Example: Hello H e l l o \ A null string occupies one byte in memory. Only the \ character 56

### Number Representation

Number Representation CS10001: Programming & Data Structures Pallab Dasgupta Professor, Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur Topics to be Discussed How are numeric data

More information

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

Data Representation Section 3.1 Data Types Registers contain either data or control information Control information is a bit or group of bits used to specify the sequence of command signals needed for

More information

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

ECE Department Summer LECTURE #5: Number Systems EEL : Digital Logic and Computer Systems Based on lecture notes by Dr. Eric M. Schwartz Decimal Number System: -Our standard number system is base, also

More information

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

LSN 2 Number Systems Department of Engineering Technology LSN 2 Decimal Number System Decimal number system has 10 digits (0-9) Base 10 weighting system... 10 5 10 4 10 3 10 2 10 1 10 0. 10-1 10-2 10-3

More information

### 198:211 Computer Architecture

198:211 Computer Architecture Topics: Lecture 8 (W5) Fall 2012 Data representation 2.1 and 2.2 of the book Floating point 2.4 of the book 1 Computer Architecture What do computers do? Manipulate stored

More information

### Levent EREN levent.eren@ieu.edu.tr A-306 Office Phone:488-9882 INTRODUCTION TO DIGITAL LOGIC

Levent EREN levent.eren@ieu.edu.tr A-306 Office Phone:488-9882 1 Number Systems Representation Positive radix, positional number systems A number with radix r is represented by a string of digits: A n

More information

### Chapter 4: Computer Codes

Slide 1/30 Learning Objectives In this chapter you will learn about: Computer data Computer codes: representation of data in binary Most commonly used computer codes Collating sequence 36 Slide 2/30 Data

More information

### Fractional Numbers. Fractional Number Notations. Fixed-point Notation. Fixed-point Notation

2 Fractional Numbers Fractional Number Notations 2010 - Claudio Fornaro Ver. 1.4 Fractional numbers have the form: xxxxxxxxx.yyyyyyyyy where the x es constitute the integer part of the value and the y

More information

### Solution for Homework 2

Solution for Homework 2 Problem 1 a. What is the minimum number of bits that are required to uniquely represent the characters of English alphabet? (Consider upper case characters alone) The number of

More information

### Signed Binary Arithmetic

Signed Binary Arithmetic In the real world of mathematics, computers must represent both positive and negative binary numbers. For example, even when dealing with positive arguments, mathematical operations

More information

### Systems I: Computer Organization and Architecture

Systems I: Computer Organization and Architecture Lecture 2: Number Systems and Arithmetic Number Systems - Base The number system that we use is base : 734 = + 7 + 3 + 4 = x + 7x + 3x + 4x = x 3 + 7x

More information

### Data Representation. Data Representation, Storage, and Retrieval. Data Representation. Data Representation. Data Representation. Data Representation

, Storage, and Retrieval ULM/HHIM Summer Program Project 3, Day 3, Part 3 Digital computers convert the data they process into a digital value. Text Audio Images/Graphics Video Digitizing 00000000... 6/8/20

More information

### Computer Science 281 Binary and Hexadecimal Review

Computer Science 281 Binary and Hexadecimal Review 1 The Binary Number System Computers store everything, both instructions and data, by using many, many transistors, each of which can be in one of two

More information

### The Essentials of Computer Organization and Architecture. Linda Null and Julia Lobur Jones and Bartlett Publishers, 2003

The Essentials of Computer Organization and Architecture Linda Null and Julia Lobur Jones and Bartlett Publishers, 2003 Chapter 2 Instructor's Manual Chapter Objectives Chapter 2, Data Representation,

More information

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

Chapter 3 Data Storage Objectives After studying this chapter, students should be able to: List five different data types used in a computer. Describe how integers are stored in a computer. Describe how

More information

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

CDA 3200 Digital Systems Instructor: Dr. Janusz Zalewski Developed by: Dr. Dahai Guo Spring 2012 Outline Data Representation Binary Codes Why 6-3-1-1 and Excess-3? Data Representation (1/2) Each numbering

More information

### Numbering Systems. InThisAppendix...

G InThisAppendix... Introduction Binary Numbering System Hexadecimal Numbering System Octal Numbering System Binary Coded Decimal (BCD) Numbering System Real (Floating Point) Numbering System BCD/Binary/Decimal/Hex/Octal

More information

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

Binary Representation The basis of all digital data is binary representation. Binary - means two 1, 0 True, False Hot, Cold On, Off We must be able to handle more than just values for real world problems

More information

### CSI 333 Lecture 1 Number Systems

CSI 333 Lecture 1 Number Systems 1 1 / 23 Basics of Number Systems Ref: Appendix C of Deitel & Deitel. Weighted Positional Notation: 192 = 2 10 0 + 9 10 1 + 1 10 2 General: Digit sequence : d n 1 d n 2...

More information

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

Chapter 3 3.1 Decimal System The radix or base of a number system determines the total number of different symbols or digits used by that system. The decimal system has a base of 10 with the digits 0 through

More information

### Activity 1: Bits and Bytes

ICS3U (Java): Introduction to Computer Science, Grade 11, University Preparation Activity 1: Bits and Bytes The Binary Number System Computers use electrical circuits that include many transistors and

More information

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

Unit- I Introduction to c Language: C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating

More information

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

EE 261 Introduction to Logic Circuits Module #2 Number Systems Topics A. Number System Formation B. Base Conversions C. Binary Arithmetic D. Signed Numbers E. Signed Arithmetic F. Binary Codes Textbook

More information

### Data Storage 3.1. Foundations of Computer Science Cengage Learning

3 Data Storage 3.1 Foundations of Computer Science Cengage Learning Objectives After studying this chapter, the student should be able to: List five different data types used in a computer. Describe how

More information

### Lecture 2. Binary and Hexadecimal Numbers

Lecture 2 Binary and Hexadecimal Numbers Purpose: Review binary and hexadecimal number representations Convert directly from one base to another base Review addition and subtraction in binary representations

More information

### Lecture 11: Number Systems

Lecture 11: Number Systems Numeric Data Fixed point Integers (12, 345, 20567 etc) Real fractions (23.45, 23., 0.145 etc.) Floating point such as 23. 45 e 12 Basically an exponent representation Any number

More information

### Lecture 4 Representing Data on the Computer. Ramani Duraiswami AMSC/CMSC 662 Fall 2009

Lecture 4 Representing Data on the Computer Ramani Duraiswami AMSC/CMSC 662 Fall 2009 x = ±(1+f) 2 e 0 f < 1 f = (integer < 2 52 )/ 2 52-1022 e 1023 e = integer Effects of floating point Effects of floating

More information

### ECE 0142 Computer Organization. Lecture 3 Floating Point Representations

ECE 0142 Computer Organization Lecture 3 Floating Point Representations 1 Floating-point arithmetic We often incur floating-point programming. Floating point greatly simplifies working with large (e.g.,

More information

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

Divide: Paper & Pencil Computer Architecture ALU Design : Division and Floating Point 1001 Quotient Divisor 1000 1001010 Dividend 1000 10 101 1010 1000 10 (or Modulo result) See how big a number can be

More information

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

Digital System Design Prof. D Roychoudhry Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture - 04 Digital Logic II May, I before starting the today s lecture

More information

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

Binary Numbers In computer science we deal almost exclusively with binary numbers. it will be very helpful to memorize some binary constants and their decimal and English equivalents. By English equivalents

More information

### Useful Number Systems

Useful Number Systems Decimal Base = 10 Digit Set = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} Binary Base = 2 Digit Set = {0, 1} Octal Base = 8 = 2 3 Digit Set = {0, 1, 2, 3, 4, 5, 6, 7} Hexadecimal Base = 16 = 2

More information

### NUMBER SYSTEMS. 1.1 Introduction

NUMBER SYSTEMS 1.1 Introduction There are several number systems which we normally use, such as decimal, binary, octal, hexadecimal, etc. Amongst them we are most familiar with the decimal number system.

More information

### Binary Representation

Binary Representation The basis of all digital data is binary representation. Binary - means two 1, 0 True, False Hot, Cold On, Off We must tbe able to handle more than just values for real world problems

More information

### HOMEWORK # 2 SOLUTIO

HOMEWORK # 2 SOLUTIO Problem 1 (2 points) a. There are 313 characters in the Tamil language. If every character is to be encoded into a unique bit pattern, what is the minimum number of bits required to

More information

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

Conversions Dr. Sarita Agarwal (Acharya Narendra Dev College,University of Delhi) INTRODUCTION System- A number system defines a set of values to represent quantity. We talk about the number of people

More information

### Base Conversion written by Cathy Saxton

Base Conversion written by Cathy Saxton 1. Base 10 In base 10, the digits, from right to left, specify the 1 s, 10 s, 100 s, 1000 s, etc. These are powers of 10 (10 x ): 10 0 = 1, 10 1 = 10, 10 2 = 100,

More information

### Review 1/2. CS61C Characters and Floating Point. Lecture 8. February 12, Review 2/2 : 12 new instructions Arithmetic:

Review 1/2 CS61C Characters and Floating Point Lecture 8 February 12, 1999 Handling case when number is too big for representation (overflow) Representing negative numbers (2 s complement) Comparing signed

More information

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

2/9/9 Binary number system Computer (electronic) systems prefer binary numbers Binary number: represent a number in base-2 Binary numbers 2 3 + 7 + 5 Some terminology Bit: a binary digit ( or ) Hexadecimal

More information

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

Today Binary addition Representing negative numbers 2 Binary Addition Consider the following binary numbers: 0 0 1 0 0 1 1 0 0 0 1 0 1 0 1 1 How do we add these numbers? 3 Binary Addition 0 0 1 0 0 1 1

More information

### Binary Numbers. Bob Brown Information Technology Department Southern Polytechnic State University

Binary Numbers Bob Brown Information Technology Department Southern Polytechnic State University Positional Number Systems The idea of number is a mathematical abstraction. To use numbers, we must represent

More information

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

Computers CMPT 125: Lecture 1: Understanding the Computer Tamara Smyth, tamaras@cs.sfu.ca School of Computing Science, Simon Fraser University January 3, 2009 A computer performs 2 basic functions: 1.

More information

### Measures of Error: for exact x and approximation x Absolute error e = x x. Relative error r = (x x )/x.

ERRORS and COMPUTER ARITHMETIC Types of Error in Numerical Calculations Initial Data Errors: from experiment, modeling, computer representation; problem dependent but need to know at beginning of calculation.

More information

### Binary Number System. 16. Binary Numbers. Base 10 digits: 0 1 2 3 4 5 6 7 8 9. Base 2 digits: 0 1

Binary Number System 1 Base 10 digits: 0 1 2 3 4 5 6 7 8 9 Base 2 digits: 0 1 Recall that in base 10, the digits of a number are just coefficients of powers of the base (10): 417 = 4 * 10 2 + 1 * 10 1

More information

### CS 16: Assembly Language Programming for the IBM PC and Compatibles

CS 16: Assembly Language Programming for the IBM PC and Compatibles First, a little about you Your name Have you ever worked with/used/played with assembly language? If so, talk about it Why are you taking

More information

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

plc numbers - 3. Topics: Number bases; binary, octal, decimal, hexadecimal Binary calculations; s compliments, addition, subtraction and Boolean operations Encoded values; BCD and ASCII Error detection;

More information

### CPEN 214 - Digital Logic Design Binary Systems

CPEN 4 - Digital Logic Design Binary Systems C. Gerousis Digital Design 3 rd Ed., Mano Prentice Hall Digital vs. Analog An analog system has continuous range of values A mercury thermometer Vinyl records

More information

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

Digital Design Assoc. Prof. Dr. Berna Örs Yalçın Istanbul Technical University Faculty of Electrical and Electronics Engineering Office Number: 2318 E-mail: siddika.ors@itu.edu.tr Grading 1st Midterm -

More information

### Binary Division. Decimal Division. Hardware for Binary Division. Simple 16-bit Divider Circuit

Decimal Division Remember 4th grade long division? 43 // quotient 12 521 // divisor dividend -480 41-36 5 // remainder Shift divisor left (multiply by 10) until MSB lines up with dividend s Repeat until

More information

### ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-470/570: Microprocessor-Based System Design Fall 2014.

REVIEW OF NUMBER SYSTEMS Notes Unit 2 BINARY NUMBER SYSTEM In the decimal system, a decimal digit can take values from to 9. For the binary system, the counterpart of the decimal digit is the binary digit,

More information

### Number Systems, Base Conversions, and Computer Data Representation

, Base Conversions, and Computer Data Representation Decimal and Binary Numbers When we write decimal (base 10) numbers, we use a positional notation system. Each digit is multiplied by an appropriate

More information

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

Exercises 1 - number representations Questions 1. Give the 16 bit signed (twos complement) representation of the following decimal numbers, and convert to hexadecimal: (a) 3012 (b) - 435 2. For each of

More information

### 4 Operations On Data

4 Operations On Data 4.1 Source: Foundations of Computer Science Cengage Learning Objectives After studying this chapter, students should be able to: List the three categories of operations performed on

More information

### The University of Nottingham

The University of Nottingham School of Computer Science A Level 1 Module, Autumn Semester 2007-2008 Computer Systems Architecture (G51CSA) Time Allowed: TWO Hours Candidates must NOT start writing their

More information

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

Binary math This worksheet and all related files are licensed under the Creative Commons Attribution License, version 1.0. To view a copy of this license, visit http://creativecommons.org/licenses/by/1.0/,

More information

### Decimal Numbers: Base 10 Integer Numbers & Arithmetic

Decimal Numbers: Base 10 Integer Numbers & Arithmetic Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Example: 3271 = (3x10 3 ) + (2x10 2 ) + (7x10 1 )+(1x10 0 ) Ward 1 Ward 2 Numbers: positional notation Number

More information

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

Numeral Systems Which number is larger? 25 8 We need to distinguish between numbers and the symbols that represent them, called numerals. The number 25 is larger than 8, but the numeral 8 above is larger

More information

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

CS101 Lecture 11: Number Systems and Binary Numbers Aaron Stevens 14 February 2011 1 2 1 3!!! MATH WARNING!!! TODAY S LECTURE CONTAINS TRACE AMOUNTS OF ARITHMETIC AND ALGEBRA PLEASE BE ADVISED THAT CALCULTORS

More information

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

Introduction to Embedded Microcomputer Systems Lecture 5.1 2.9. Conversions ASCII to binary n = 100*(Data[0]-0x30) + 10*(Data[1]-0x30) + (Data[2]-0x30); This 3-digit ASCII string could also be calculated

More information

### Primitive Data Types Summer 2010 Margaret Reid-Miller

Primitive Data Types 15-110 Summer 2010 Margaret Reid-Miller Data Types Data stored in memory is a string of bits (0 or 1). What does 1000010 mean? 66? 'B'? 9.2E-44? How the computer interprets the string

More information

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

The New IoT Standard: Any App for Any Device Using Any Data Format Mike Weiner Product Manager, Omega DevCloud KORE Telematics About KORE The world s largest M2M/IoT services provider 12 Carriers Enterprise

More information

### CS321. Introduction to Numerical Methods

CS3 Introduction to Numerical Methods Lecture Number Representations and Errors Professor Jun Zhang Department of Computer Science University of Kentucky Lexington, KY 40506-0633 August 7, 05 Number in

More information

### Binary Numbering Systems

Binary Numbering Systems April 1997, ver. 1 Application Note 83 Introduction Binary numbering systems are used in virtually all digital systems, including digital signal processing (DSP), networking, and

More information

### quotient = dividend / divisor, with a remainder Given dividend and divisor, we want to obtain quotient (Q) and remainder (R)

Binary division quotient = dividend / divisor, with a remainder dividend = divisor quotient + remainder Given dividend and divisor, we want to obtain quotient (Q) and remainder (R) We will start from our

More information

### COMPSCI 210. Binary Fractions. Agenda & Reading

COMPSCI 21 Binary Fractions Agenda & Reading Topics: Fractions Binary Octal Hexadecimal Binary -> Octal, Hex Octal -> Binary, Hex Decimal -> Octal, Hex Hex -> Binary, Octal Animation: BinFrac.htm Example

More information

### Binary Numbers. Binary Octal Hexadecimal

Binary Numbers Binary Octal Hexadecimal Binary Numbers COUNTING SYSTEMS UNLIMITED... Since you have been using the 10 different digits 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 all your life, you may wonder how

More information

### This Unit: Floating Point Arithmetic. CIS 371 Computer Organization and Design. Readings. Floating Point (FP) Numbers

This Unit: Floating Point Arithmetic CIS 371 Computer Organization and Design Unit 7: Floating Point App App App System software Mem CPU I/O Formats Precision and range IEEE 754 standard Operations Addition

More information

### Pemrograman Dasar. Basic Elements Of Java

Pemrograman Dasar Basic Elements Of Java Compiling and Running a Java Application 2 Portable Java Application 3 Java Platform Platform: hardware or software environment in which a program runs. Oracle

More information

### The programming language C. sws1 1

The programming language C sws1 1 The programming language C invented by Dennis Ritchie in early 1970s who used it to write the first Hello World program C was used to write UNIX Standardised as K&C (Kernighan

More information

### > 2. Error and Computer Arithmetic

> 2. Error and Computer Arithmetic Numerical analysis is concerned with how to solve a problem numerically, i.e., how to develop a sequence of numerical calculations to get a satisfactory answer. Part

More information

### Number and codes in digital systems

Number and codes in digital systems Decimal Numbers You are familiar with the decimal number system because you use them everyday. But their weighted structure is not understood. In the decimal number

More information

### Introduction to Programming

Introduction to Programming SS 2012 Adrian Kacso, Univ. Siegen adriana.dkacsoa@duni-siegena.de Tel.: 0271/740-3966, Office: H-B 8406 Stand: April 25, 2012 Betriebssysteme / verteilte Systeme Introduction

More information

### Restoring division. 2. Run the algorithm Let s do 0111/0010 (7/2) unsigned. 3. Find remainder here. 4. Find quotient here.

Binary division Dividend = divisor q quotient + remainder CS/COE447: Computer Organization and Assembly Language Given dividend and divisor, we want to obtain quotient (Q) and remainder (R) Chapter 3 We

More information

### NUMBER SYSTEMS. William Stallings

NUMBER SYSTEMS William Stallings The Decimal System... The Binary System...3 Converting between Binary and Decimal...3 Integers...4 Fractions...5 Hexadecimal Notation...6 This document available at WilliamStallings.com/StudentSupport.html

More information

### Encoding Text with a Small Alphabet

Chapter 2 Encoding Text with a Small Alphabet Given the nature of the Internet, we can break the process of understanding how information is transmitted into two components. First, we have to figure out

More information

### Binary, Hexadecimal, Octal, and BCD Numbers

23CH_PHCalter_TMSETE_949118 23/2/2007 1:37 PM Page 1 Binary, Hexadecimal, Octal, and BCD Numbers OBJECTIVES When you have completed this chapter, you should be able to: Convert between binary and decimal

More information

### DNA Data and Program Representation. Alexandre David 1.2.05 adavid@cs.aau.dk

DNA Data and Program Representation Alexandre David 1.2.05 adavid@cs.aau.dk Introduction Very important to understand how data is represented. operations limits precision Digital logic built on 2-valued

More information

### Digital Logic Design. Introduction

Digital Logic Design Introduction A digital computer stores data in terms of digits (numbers) and proceeds in discrete steps from one state to the next. The states of a digital computer typically involve

More information

### Binary. ! You are probably familiar with decimal

Arithmetic operations in assembly language Prof. Gustavo Alonso Computer Science Department ETH Zürich alonso@inf.ethz.ch http://www.inf.ethz.ch/department/is/iks/ Binary! You are probably familiar with

More information

### Simulation & Synthesis Using VHDL

Floating Point Multipliers: Simulation & Synthesis Using VHDL By: Raj Kumar Singh - B.E. (Hons.) Electrical & Electronics Shivananda Reddy - B.E. (Hons.) Electrical & Electronics BITS, PILANI Outline Introduction

More information

### Binary Numbers The Computer Number System

Binary Numbers The Computer Number System Number systems are simply ways to count things. Ours is the base-0 or radix-0 system. Note that there is no symbol for 0 or for the base of any system. We count,2,3,4,5,6,7,8,9,

More information

### = Chapter 1. The Binary Number System. 1.1 Why Binary?

Chapter The Binary Number System. Why Binary? The number system that you are familiar with, that you use every day, is the decimal number system, also commonly referred to as the base-0 system. When you

More information

### Bits, bytes, and representation of information

Bits, bytes, and representation of information digital representation means that everything is represented by numbers only the usual sequence: something (sound, pictures, text, instructions,...) is converted

More information

### Unsigned Conversions from Decimal or to Decimal and other Number Systems

Page 1 of 5 Unsigned Conversions from Decimal or to Decimal and other Number Systems In all digital design, analysis, troubleshooting, and repair you will be working with binary numbers (or base 2). It

More information

### Section 1.4 Place Value Systems of Numeration in Other Bases

Section.4 Place Value Systems of Numeration in Other Bases Other Bases The Hindu-Arabic system that is used in most of the world today is a positional value system with a base of ten. The simplest reason

More information

### Chapter 1: Digital Systems and Binary Numbers

Chapter 1: Digital Systems and Binary Numbers Digital age and information age Digital computers general purposes many scientific, industrial and commercial applications Digital systems telephone switching

More information

### 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

Other architectures Example. Accumulator-based machines A single register, called the accumulator, stores the operand before the operation, and stores the result after the operation. Load x # into acc

More information

### ASCII Characters. 146 CHAPTER 3 Information Representation. The sign bit is 1, so the number is negative. Converting to decimal gives

146 CHAPTER 3 Information Representation The sign bit is 1, so the number is negative. Converting to decimal gives 37A (hex) = 134 (dec) Notice that the hexadecimal number is not written with a negative

More information

### Chapter 2. Binary Values and Number Systems

Chapter 2 Binary Values and Number Systems Numbers Natural numbers, a.k.a. positive integers Zero and any number obtained by repeatedly adding one to it. Examples: 100, 0, 45645, 32 Negative numbers A

More information

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

Number Bases //9 Goals Numbers Understand binary and hexadecimal numbers Be able to convert between number bases Understand binary fractions COMP37 Introduction to Computer Architecture Unary Numbers Decimal

More information

### 3. Convert a number from one number system to another

3. Convert a number from one number system to another Conversion between number bases: Hexa (16) Decimal (10) Binary (2) Octal (8) More Interest Way we need conversion? We need decimal system for real

More information

### Chapter 7D The Java Virtual Machine

This sub chapter discusses another architecture, that of the JVM (Java Virtual Machine). In general, a VM (Virtual Machine) is a hypothetical machine (implemented in either hardware or software) that directly

More information

### INTRODUCTION TO FLOWCHARTING

CHAPTER 1 INTRODUCTION TO FLOWCHARTING 1.0 Objectives 1.1 Introduction 1.2 Flowcharts 1.3 Types of Flowcharts 1.3.1 Types of flowchart 1.3.2 System flowcharts 1.4 Flowchart Symbols 1.5 Advantages of Flowcharts

More information

### Numerical Matrix Analysis

Numerical Matrix Analysis Lecture Notes #10 Conditioning and / Peter Blomgren, blomgren.peter@gmail.com Department of Mathematics and Statistics Dynamical Systems Group Computational Sciences Research

More information

### 2. Compressing data to reduce the amount of transmitted data (e.g., to save money).

Presentation Layer The presentation layer is concerned with preserving the meaning of information sent across a network. The presentation layer may represent (encode) the data in various ways (e.g., data

More information

### Chapter 1. Binary, octal and hexadecimal numbers

Chapter 1. Binary, octal and hexadecimal numbers This material is covered in the books: Nelson Magor Cooke et al, Basic mathematics for electronics (7th edition), Glencoe, Lake Forest, Ill., 1992. [Hamilton

More information

### Cyber Security Workshop Encryption Reference Manual

Cyber Security Workshop Encryption Reference Manual May 2015 Basic Concepts in Encoding and Encryption Binary Encoding Examples Encryption Cipher Examples 1 P a g e Encoding Concepts Binary Encoding Basics

More information

### Correctly Rounded Floating-point Binary-to-Decimal and Decimal-to-Binary Conversion Routines in Standard ML. By Prashanth Tilleti

Correctly Rounded Floating-point Binary-to-Decimal and Decimal-to-Binary Conversion Routines in Standard ML By Prashanth Tilleti Advisor Dr. Matthew Fluet Department of Computer Science B. Thomas Golisano

More information

### Arithmetic in MIPS. Objectives. Instruction. Integer arithmetic. After completing this lab you will:

6 Objectives After completing this lab you will: know how to do integer arithmetic in MIPS know how to do floating point arithmetic in MIPS know about conversion from integer to floating point and from

More information

### Number Systems and Radix Conversion

Number Systems and Radix Conversion Sanjay Rajopadhye, Colorado State University 1 Introduction These notes for CS 270 describe polynomial number systems. The material is not in the textbook, but will

More information