Size: px
Start display at page:

Transcription

2 Unsigned vs. Two s Complement 8-bit example: = = = = -61 Why does two s complement work this way?

4 Unsigned ints on the number line N - 1

5 Unsigned Integers Suppose we had one byte Can represent 2 8 (256) values If unsigned (strictly non-negative): = = = = What if we add one more? Car odometer rolls over.

6 Unsigned Overflow If we add two N-bit unsigned integers, the answer can t be more than 2 N When there should be a carry from the last digit, it is lost. This is called overflow, and the result of the addition is incorrect.

7 In cs31, the number line is a circle 255 ( ) 0 Addition This means that all arithmetic is modular. With 8 bits, arithmetic is mod 2 8 ; with N bits arithmetic is mod 2 N = 259 % 256 = ( )

8 Suppose we want to support negative values too (-127 to 127). Where should we put -1 and -127 on the circle? Why? -127 ( ) 0-1 ( ) 0 A B C: Put them somewhere else.

9 Option B is Two s Complement Borrows nice properties from the number line: Addition Addition Only one instance of zero, with -1 and 1 on either side of it. Addition: moves to the right Like wrapping number line around a circle

10 Does two s complement, solve the rolling over (overflow) problem? A. Yes, it s gone B. Nope, it s still there. C. It s even worse now. This is an issue we need to be aware of when adding and subtracting!

11 Overflow, Revisited Danger Zone endpoints of unsigned number line Signed 192 Unsigned Danger Zone endpoints of signed number line

12 If we add a positive number and a negative number, will we have overflow? (Assume they are the same # of bits) A. Always B. Sometimes Signed C. Never Danger Zone

13 Signed Overflow Overflow: IFF the sign bits of operands are the same, but the sign bit of result is different. Not enough bits to store result! -1 Signed addition (and subtraction): 7=7 2+-1=1 2+-2=0 2+-4=-2 2+7= Signed 1 No chance of overflow here - signs of operands are different! -128

14 Signed Overflow Overflow: IFF the sign bits of operands are the same, but the sign bit of result is different. Not enough bits to store result! Signed addition (and subtraction): 2+-1=1 2+-2=0 2+-4=-2 2+7= = Overflow here! Operand signs are the same, and they don t match output sign!

15 Overflow Rules Signed: The sign bits of operands are the same, but the sign bit of result is different. Can we formalize unsigned overflow? Need to include subtraction too, skipped it before.

16 Recall Subtraction Hardware Negate and add 1 to second operand: Can use the same circuit for add and subtract: 6-7 == 6 + ~7 + 1 input > input 2 --> possible bit flipper --> ADD CIRCUIT ---> result possible +1 input > Let s call this +1 input: Carry in

17 How many of these unsigned operations have overflowed? 4 bit unsigned values (range 0 to 15): carry-in carry-out Addition (carry-in = 0) = = = = = = Subtraction (carry-in = 1) 6-3 = = = = A. 1 B. 2 C. 3 D. 4 E. 5 (~3) (~6)

18 How many of these unsigned operations have overflowed? 4 bit unsigned values (range 0 to 15): carry-in carry-out Addition (carry-in = 0) = = = = = = = = = 9 Subtraction (carry-in = 1) 6-3 = = = = = = 13 A. 1 B. 2 C. 3 D. 4 E. 5 (~3) (~6) What s the pattern?

19 Overflow Rule Summary Signed overflow: The sign bits of operands are the same, but the sign bit of result is different. Unsigned: overflow The carry-in bit is different from the carry-out. C in C out C in XOR C out So far, all arithmetic on values that were the same size. What if they re different?

20 Suppose we have a signed 8-bit value, (22), and we want to add it to a signed 4-bit value, 1011 (-5). How should we represent the four-bit value? A (don t change it) B (pad the beginning with 0 s) C (pad the beginning with 1 s) D. Represent it some other way.

21 Sign Extension When combining signed values of different sizes, expand the smaller to equivalent larger size: char y=2, x=-13; short z = 10; z = z + y; z = z + x; Fill in high-order bits with sign-bit value to get same numeric value in larger number of bytes.

22 Let s verify that this works 4-bit signed value, sign extend to 8-bits, is it the same value? > obviously still > is this still -6? = -6 yes!

23 Operations on Bits For these, doesn t matter how the bits are interpreted (signed vs. unsigned) Bit-wise operators (AND, OR, NOT, XOR) Bit shifting

24 Bit-wise Operators bit operands, bit result (interpret as you please) & (AND) (OR) ~(NOT) ^(XOR) A B A & B A B ~A A ^ B ~ & ^

25 More Operations on Bits Bit-shift operators: << left shift, >> right shift << 2 is high-order bits shifted out 2 low-order bits filled with << 4 is >> 2 is >> 4 is >> 2 is (logical shift) or (arithmetic shift) Arithmetic right shift: fills high-order bits w/sign bit C automatically decides which to use based on type: signed: arithmetic, unsigned: logical

26 Floating Point Representation 1 bit for sign sign exponent fraction 8 bits for exponent 23 bits for precision I don t expect you to memorize this value = (-1) sign * 1.fraction * 2 (exponent-127) let's just plug in some values and try it out 0x40ac49ba: sign = 0 exp = 129 fraction = = 1* *2 2 = Think of scientific notation: 1.933e-4 = * 10-4

27 Character Representation Represented as one-byte integers using ASCII. ASCII maps the range to letters, punctuation, etc.

28 Characters and strings in C char c = J ; char s[6] = hello ; s[0] = c; printf( %s\n, s); Will print: Jello Character literals are surrounded by single quotes. String literals are surrounded by double quotes. Strings are stored as arrays of characters.

29 Discussion question: how can we tell where a string ends? A. Mark the end of the string with a special character. B. Associate a length value with the string, and use that to store its current length. C. A string is always the full length of the array it s contained within (e.g., char name[20] must be of length 20). D. All of these could work (which is best?). E. Some other mechanism (such as?).

30 What will this snippet print? char c = J ; char s[6] = hello ; s[5] = c; printf( %s\n, s); A. Jello B. hellj C. helloj D. Something else, that we can determine. E. Something else, but we can t tell what.

### CS 31: Intro to Systems Binary Arithmetic. Kevin Webb Swarthmore College January 26, 2016

CS 31: Intro to Systems Binary Arithmetic Kevin Webb Swarthmore College January 26, 2016 Reading Quiz Unsigned Integers Suppose we had one byte Can represent 2 8 (256) values If unsigned (strictly non-negative):

### CS 31: Introduction to Computer Systems. 03: Binary Arithmetic January 29

CS 31: Introduction to Computer Systems 03: Binary Arithmetic January 29 WiCS! Swarthmore Women in Computer Science Slide 2 Today Binary Arithmetic Unsigned addition Subtraction Representation Signed magnitude

### CS 31: Intro to Systems Binary Arithmetic. Martin Gagné Swarthmore College January 24, 2016

CS 31: Intro to Systems Binary Arithmetic Martin Gagné Swarthmore College January 24, 2016 Unsigned Integers Suppose we had one byte Can represent 2 8 (256) values If unsigned (strictly non-negative):

### Inf2C - Computer Systems Lecture 2 Data Representation

Inf2C - Computer Systems Lecture 2 Data Representation Boris Grot School of Informatics University of Edinburgh Last lecture Moore s law Types of computer systems Computer components Computer system stack

### Bits, Words, and Integers

Computer Science 52 Bits, Words, and Integers Spring Semester, 2017 In this document, we look at how bits are organized into meaningful data. In particular, we will see the details of how integers are

### Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Bits and Bytes and Numbers

Computer Science 324 Computer Architecture Mount Holyoke College Fall 2007 Topic Notes: Bits and Bytes and Numbers Number Systems Much of this is review, given the 221 prerequisite Question: how high can

### 10.1. Unit 10. Signed Representation Systems Binary Arithmetic

0. Unit 0 Signed Representation Systems Binary Arithmetic 0.2 BINARY REPRESENTATION SYSTEMS REVIEW 0.3 Interpreting Binary Strings Given a string of s and 0 s, you need to know the representation system

### Goals for this Week. CSC 2400: Computer Systems. Bits, Bytes and Data Types. Binary number system. Finite representations of binary integers

CSC 2400: Computer Systems Bits, Bytes and Data Types 1 Goals for this Week Binary number system Why binary? Converting between decimal and binary and octal and hexadecimal number systems Finite representations

### Integer Representation

Integer Representation Announcements assign0 due tonight assign1 out tomorrow Labs start this week SCPD Note on ofce hours on Piazza Will get an email tonight about labs Goals for Today Introduction to

### Kinds Of Data CHAPTER 3 DATA REPRESENTATION. Numbers Are Different! Positional Number Systems. Text. Numbers. Other

Kinds Of Data CHAPTER 3 DATA REPRESENTATION Numbers Integers Unsigned Signed Reals Fixed-Point Floating-Point Binary-Coded Decimal Text ASCII Characters Strings Other Graphics Images Video Audio Numbers

### CS 31: Intro to Systems Binary Representation. Kevin Webb Swarthmore College January 27, 2015

CS 3: Intro to Systems Binary Representation Kevin Webb Swarthmore College January 27, 25 Reading Quiz Abstraction User / Programmer Wants low complexity Applications Specific functionality Software library

### Getting started with Java

Getting started with Java Magic Lines public class MagicLines { public static void main(string[] args) { } } Comments Comments are lines in your code that get ignored during execution. Good for leaving

### COMP2611: Computer Organization. Data Representation

COMP2611: Computer Organization Comp2611 Fall 2015 2 1. Binary numbers and 2 s Complement Numbers 3 Bits: are the basis for binary number representation in digital computers What you will learn here: How

### Binary Representations and Arithmetic

Binary Representations and Arithmetic 9--26 Common number systems. Base : decimal Base 2: binary Base 6: hexadecimal (memory addresses) Base 8: octal (obsolete computer systems) Base 64 (email attachments,

### CS 31: Intro to Systems Binary Representation. Kevin Webb Swarthmore College September 6, 2018

CS 3: Intro to Systems Binary Representation Kevin Webb Swarthmore College September 6, 28 Reading Quiz Announcements Sign up for Piazza! Let me know about exam conflicts! Register your clicker (clarification

### Topic Notes: Bits and Bytes and Numbers

Computer Science 220 Assembly Language & Comp Architecture Siena College Fall 2010 Topic Notes: Bits and Bytes and Numbers Binary Basics At least some of this will be review, but we will go over it for

### Chapter 3: Arithmetic for Computers

Chapter 3: Arithmetic for Computers Objectives Signed and Unsigned Numbers Addition and Subtraction Multiplication and Division Floating Point Computer Architecture CS 35101-002 2 The Binary Numbering

### C++ Data Types. 1 Simple C++ Data Types 2. 3 Numeric Types Integers (whole numbers) Decimal Numbers... 5

C++ Data Types Contents 1 Simple C++ Data Types 2 2 Quick Note About Representations 3 3 Numeric Types 4 3.1 Integers (whole numbers)............................................ 4 3.2 Decimal Numbers.................................................

### Number System. Introduction. Decimal Numbers

Number System Introduction Number systems provide the basis for all operations in information processing systems. In a number system the information is divided into a group of symbols; for example, 26

### CS 101: Computer Programming and Utilization

CS 101: Computer Programming and Utilization Jul-Nov 2017 Umesh Bellur (cs101@cse.iitb.ac.in) Lecture 3: Number Representa.ons Representing Numbers Digital Circuits can store and manipulate 0 s and 1 s.

### Topic Notes: Bits and Bytes and Numbers

Computer Science 220 Assembly Language & Comp Architecture Siena College Fall 2011 Topic Notes: Bits and Bytes and Numbers Binary Basics At least some of this will be review for most of you, but we start

### Week 3 Lecture 2. Types Constants and Variables

Lecture 2 Types Constants and Variables Types Computers store bits: strings of 0s and 1s Types define how bits are interpreted They can be integers (whole numbers): 1, 2, 3 They can be characters 'a',

### Integers. N = sum (b i * 2 i ) where b i = 0 or 1. This is called unsigned binary representation. i = 31. i = 0

Integers So far, we've seen how to convert numbers between bases. How do we represent particular kinds of data in a certain (32-bit) architecture? We will consider integers floating point characters What

### Signed Multiplication Multiply the positives Negate result if signs of operand are different

Another Improvement Save on space: Put multiplier in product saves on speed: only single shift needed Figure: Improved hardware for multiplication Signed Multiplication Multiply the positives Negate result

### Signed umbers. Sign/Magnitude otation

Signed umbers So far we have discussed unsigned number representations. In particular, we have looked at the binary number system and shorthand methods in representing binary codes. With m binary digits,

### How a computer runs a program. Binary Representa8on and Opera8ons on Binary Data. Opera8ng System 9/17/13. You can view binary file contents

Consider the following type defini8on and variable declara8ons: struct persont { struct persont p1; char name[32]; int age; struct persont people[40] float heart_rate; }; (1) What type is each of the following

### l l l l l l l Base 2; each digit is 0 or 1 l Each bit in place i has value 2 i l Binary representation is used in computers

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 Computer Architecture What do computers do? Manipulate stored information

### Logic, Words, and Integers

Computer Science 52 Logic, Words, and Integers 1 Words and Data The basic unit of information in a computer is the bit; it is simply a quantity that takes one of two values, 0 or 1. A sequence of k bits

### Computer System and programming in C

1 Basic Data Types Integral Types Integers are stored in various sizes. They can be signed or unsigned. Example Suppose an integer is represented by a byte (8 bits). Leftmost bit is sign bit. If the sign

### Objects and Types. COMS W1007 Introduction to Computer Science. Christopher Conway 29 May 2003

Objects and Types COMS W1007 Introduction to Computer Science Christopher Conway 29 May 2003 Java Programs A Java program contains at least one class definition. public class Hello { public static void

### A Java program contains at least one class definition.

Java Programs Identifiers Objects and Types COMS W1007 Introduction to Computer Science Christopher Conway 29 May 2003 A Java program contains at least one class definition. public class Hello { public

### Time: 8:30-10:00 pm (Arrive at 8:15 pm) Location What to bring:

ECE 120 Midterm 1 HKN Review Session Time: 8:30-10:00 pm (Arrive at 8:15 pm) Location: Your Room on Compass What to bring: icard, pens/pencils, Cheat sheet (Handwritten) Overview of Review Binary IEEE

### Chapter 4: Data Representations

Chapter 4: Data Representations Integer Representations o unsigned o sign-magnitude o one's complement o two's complement o bias o comparison o sign extension o overflow Character Representations Floating

### These are reserved words of the C language. For example int, float, if, else, for, while etc.

Tokens in C Keywords These are reserved words of the C language. For example int, float, if, else, for, while etc. Identifiers An Identifier is a sequence of letters and digits, but must start with a letter.

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

The type of all data used in a C (or C++) program must be specified A data type is a description of the data being represented That is, a set of possible values and a set of operations on those values

### Numerical Precision. Or, why my numbers aren t numbering right. 1 of 15

Numerical Precision Or, why my numbers aren t numbering right 1 of 15 What s the deal? Maybe you ve seen this #include int main() { float val = 3.6f; printf( %.20f \n, val); Print a float with

### ISA 563 : Fundamentals of Systems Programming

ISA 563 : Fundamentals of Systems Programming Variables, Primitive Types, Operators, and Expressions September 4 th 2008 Outline Define Expressions Discuss how to represent data in a program variable name

### CSCI 6610: Review. Chapter 7: Numbers Chapter 8: Characters Chapter 11 Pointers

... 1/27 CSCI 6610: Review Chapter 7: Numbers Chapter 8: Characters Chapter 11 Pointers Alice E. Fischer February 1, 2016 ... 2/27 Outline The Trouble with Numbers The char Data Types Pointers ... 3/27

### Slide Set 2. for ENCM 335 in Fall Steve Norman, PhD, PEng

Slide Set 2 for ENCM 335 in Fall 2018 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary September 2018 ENCM 335 Fall 2018 Slide Set 2 slide

### Numbers and Computers. Debdeep Mukhopadhyay Assistant Professor Dept of Computer Sc and Engg IIT Madras

Numbers and Computers Debdeep Mukhopadhyay Assistant Professor Dept of Computer Sc and Engg IIT Madras 1 Think of a number between 1 and 15 8 9 10 11 12 13 14 15 4 5 6 7 12 13 14 15 2 3 6 7 10 11 14 15

### Chapter 2 Bits, Data Types, and Operations

Chapter 2 Bits, Data Types, and Operations Original slides from Gregory Byrd, North Carolina State University Modified slides by Chris Wilcox, Colorado State University How do we represent data in a computer?!

### Computer (Literacy) Skills. Number representations and memory. Lubomír Bulej KDSS MFF UK

Computer (Literacy Skills Number representations and memory Lubomír Bulej KDSS MFF UK Number representations? What for? Recall: computer works with binary numbers Groups of zeroes and ones 8 bits (byte,

### CS 261 Fall Floating-Point Numbers. Mike Lam, Professor. https://xkcd.com/217/

CS 261 Fall 2017 Mike Lam, Professor https://xkcd.com/217/ Floating-Point Numbers Floating-point Topics Binary fractions Floating-point representation Conversions and rounding error Binary fractions Now

### M1 Computers and Data

M1 Computers and Data Module Outline Architecture vs. Organization. Computer system and its submodules. Concept of frequency. Processor performance equation. Representation of information characters, signed

### As stated earlier, the declaration

The int data type As stated earlier, the declaration int a; is an instruction to the compiler to reserve a certain amount of memory to hold the values of the variable a. How much memory? Two bytes (usually,

### COMP2121: Microprocessors and Interfacing. Number Systems

COMP2121: Microprocessors and Interfacing Number Systems http://www.cse.unsw.edu.au/~cs2121 Lecturer: Hui Wu Session 2, 2017 1 1 Overview Positional notation Decimal, hexadecimal, octal and binary Converting

### The Design of C: A Rational Reconstruction

The Design of C: A Rational Reconstruction 1 Goals of this Lecture Help you learn about: The decisions that were available to the designers of C The decisions that were made by the designers of C and thereby

### Introduction to Computers and Programming. Numeric Values

Introduction to Computers and Programming Prof. I. K. Lundqvist Lecture 5 Reading: B pp. 47-71 Sept 1 003 Numeric Values Storing the value of 5 10 using ASCII: 00110010 00110101 Binary notation: 00000000

### Computer Organization

Computer Organization Register Transfer Logic Number System Department of Computer Science Missouri University of Science & Technology hurson@mst.edu 1 Decimal Numbers: Base 10 Digits: 0, 1, 2, 3, 4, 5,

### The Design of C: A Rational Reconstruction"

The Design of C: A Rational Reconstruction 1 Goals of this Lecture Help you learn about: The decisions that were available to the designers of C The decisions that were made by the designers of C and thereby

### Arithmetic and Bitwise Operations on Binary Data

Arithmetic and Bitwise Operations on Binary Data CSCI 2400: Computer Architecture ECE 3217: Computer Architecture and Organization Instructor: David Ferry Slides adapted from Bryant & O Hallaron s slides

### CS 261 Fall Floating-Point Numbers. Mike Lam, Professor.

CS 261 Fall 2018 Mike Lam, Professor https://xkcd.com/217/ Floating-Point Numbers Floating-point Topics Binary fractions Floating-point representation Conversions and rounding error Binary fractions Now

### More Programming Constructs -- Introduction

More Programming Constructs -- Introduction We can now examine some additional programming concepts and constructs Chapter 5 focuses on: internal data representation conversions between one data type and

### Binary representation of integer numbers Operations on bits

Outline Binary representation of integer numbers Operations on bits The Bitwise AND Operator The Bitwise Inclusive-OR Operator The Bitwise Exclusive-OR Operator The Ones Complement Operator The Left Shift

### CSC201, SECTION 002, Fall 2000: Homework Assignment #2

1 of 7 11/8/2003 7:34 PM CSC201, SECTION 002, Fall 2000: Homework Assignment #2 DUE DATE Monday, October 2, at the start of class. INSTRUCTIONS FOR PREPARATION Neat, in order, answers easy to find. Staple

### Fundamental of Programming (C)

Borrowed from lecturer notes by Omid Jafarinezhad Fundamental of Programming (C) Lecturer: Vahid Khodabakhshi Lecture 3 Constants, Variables, Data Types, And Operations Department of Computer Engineering

### CS 261 Fall Mike Lam, Professor Integer Encodings

CS 261 Fall 2018 Mike Lam, Professor https://xkcd.com/571/ Integer Encodings Integers Topics C integer data types Unsigned encoding Signed encodings Conversions Integer data types in C99 1 byte 2 bytes

### CS113: Lecture 3. Topics: Variables. Data types. Arithmetic and Bitwise Operators. Order of Evaluation

CS113: Lecture 3 Topics: Variables Data types Arithmetic and Bitwise Operators Order of Evaluation 1 Variables Names of variables: Composed of letters, digits, and the underscore ( ) character. (NO spaces;

### Review: Exam 1. Your First C++ Program. Declaration Statements. Tells the compiler. Examples of declaration statements

Review: Exam 1 9/20/06 CS150 Introduction to Computer Science 1 1 Your First C++ Program 1 //*********************************************************** 2 // File name: hello.cpp 3 // Author: Shereen Khoja

### Basic Definition INTEGER DATA. Unsigned Binary and Binary-Coded Decimal. BCD: Binary-Coded Decimal

Basic Definition REPRESENTING INTEGER DATA Englander Ch. 4 An integer is a number which has no fractional part. Examples: -2022-213 0 1 514 323434565232 Unsigned and -Coded Decimal BCD: -Coded Decimal

### Will introduce various operators supported by C language Identify supported operations Present some of terms characterizing operators

Operators Overview Will introduce various operators supported by C language Identify supported operations Present some of terms characterizing operators Operands and Operators Mathematical or logical relationships

### Physics 306 Computing Lab 5: A Little Bit of This, A Little Bit of That

Physics 306 Computing Lab 5: A Little Bit of This, A Little Bit of That 1. Introduction You have seen situations in which the way numbers are stored in a computer affects a program. For example, in the

### Chapter 2 Bits, Data Types, and Operations

Chapter Bits, Data Types, and Operations How do we represent data in a computer? At the lowest level, a computer is an electronic machine. works by controlling the flow of electrons Easy to recognize two

### CHW 261: Logic Design

CHW 261: Logic Design Instructors: Prof. Hala Zayed Dr. Ahmed Shalaby http://www.bu.edu.eg/staff/halazayed14 http://bu.edu.eg/staff/ahmedshalaby14# Slide 1 Slide 2 Slide 3 Digital Fundamentals CHAPTER

### 2.1. Unit 2. Integer Operations (Arithmetic, Overflow, Bitwise Logic, Shifting)

2.1 Unit 2 Integer Operations (Arithmetic, Overflow, Bitwise Logic, Shifting) 2.2 Skills & Outcomes You should know and be able to apply the following skills with confidence Perform addition & subtraction

### IT 1204 Section 2.0. Data Representation and Arithmetic. 2009, University of Colombo School of Computing 1

IT 1204 Section 2.0 Data Representation and Arithmetic 2009, University of Colombo School of Computing 1 What is Analog and Digital The interpretation of an analog signal would correspond to a signal whose

### 4/8/17. Admin. Assignment 5 BINARY. David Kauchak CS 52 Spring 2017

4/8/17 Admin! Assignment 5 BINARY David Kauchak CS 52 Spring 2017 Diving into your computer Normal computer user 1 After intro CS After 5 weeks of cs52 What now One last note on CS52 memory address binary

### Floating Point Arithmetic

Floating Point Arithmetic CS 365 Floating-Point What can be represented in N bits? Unsigned 0 to 2 N 2s Complement -2 N-1 to 2 N-1-1 But, what about? very large numbers? 9,349,398,989,787,762,244,859,087,678

### CMPSCI 145 MIDTERM #1 Solution Key. SPRING 2017 March 3, 2017 Professor William T. Verts

CMPSCI 145 MIDTERM #1 Solution Key NAME SPRING 2017 March 3, 2017 PROBLEM SCORE POINTS 1 10 2 10 3 15 4 15 5 20 6 12 7 8 8 10 TOTAL 100 10 Points Examine the following diagram of two systems, one involving

### 2. MACHINE REPRESENTATION OF TYPICAL ARITHMETIC DATA FORMATS (NATURAL AND INTEGER NUMBERS).

2. MACHINE REPRESENTATION OF TYPICAL ARITHMETIC DATA FORMATS (NATURAL AND INTEGER NUMBERS). 2.. Natural Binary Code (NBC). The positional code with base 2 (B=2), introduced in Exercise, is used to encode

Binary Addition The rules for binary addition are 0 + 0 = 0 Sum = 0, carry = 0 0 + 1 = 0 Sum = 1, carry = 0 1 + 0 = 0 Sum = 1, carry = 0 1 + 1 = 10 Sum = 0, carry = 1 When an input carry = 1 due to a previous

### Binary Addition & Subtraction. Unsigned and Sign & Magnitude numbers

Binary Addition & Subtraction Unsigned and Sign & Magnitude numbers Addition and subtraction of unsigned or sign & magnitude binary numbers by hand proceeds exactly as with decimal numbers. (In fact this

### 9/3/2015. Data Representation II. 2.4 Signed Integer Representation. 2.4 Signed Integer Representation

Data Representation II CMSC 313 Sections 01, 02 The conversions we have so far presented have involved only unsigned numbers. To represent signed integers, computer systems allocate the high-order bit

### CS 64 Week 1 Lecture 1. Kyle Dewey

CS 64 Week 1 Lecture 1 Kyle Dewey Overview Bitwise operation wrap-up Two s complement Addition Subtraction Multiplication (if time) Bitwise Operation Wrap-up Shift Left Move all the bits N positions to

### ECE 250 / CS 250 Computer Architecture. C to Binary: Memory & Data Representations. Benjamin Lee

ECE 250 / CS 250 Computer Architecture C to Binary: Memory & Data Representations Benjamin Lee Slides based on those from Alvin Lebeck, Daniel Sorin, Andrew Hilton, Amir Roth, Gershon Kedem Administrivia

### Chapter 2. Data Representation in Computer Systems

Chapter 2 Data Representation in Computer Systems Chapter 2 Objectives Understand the fundamentals of numerical data representation and manipulation in digital computers. Master the skill of converting

### Chapter 2 Bits, Data Types, and Operations

Chapter 2 Bits, Data Types, and Operations How do we represent data in a computer? At the lowest level, a computer is an electronic machine. works by controlling the flow of electrons Easy to recognize

### CS367 Test 1 Review Guide

CS367 Test 1 Review Guide This guide tries to revisit what topics we've covered, and also to briefly suggest/hint at types of questions that might show up on the test. Anything on slides, assigned reading,

### Data Representation. DRAM uses a single capacitor to store and a transistor to select. SRAM typically uses 6 transistors.

Data Representation Data Representation Goal: Store numbers, characters, sets, database records in the computer. What we got: Circuit that stores 2 voltages, one for logic ( volts) and one for logic (3.3

### DRAM uses a single capacitor to store and a transistor to select. SRAM typically uses 6 transistors.

Data Representation Data Representation Goal: Store numbers, characters, sets, database records in the computer. What we got: Circuit that stores 2 voltages, one for logic 0 (0 volts) and one for logic

### Representing Information. Bit Juggling. - Representing information using bits - Number representations. - Some other bits - Chapters 1 and 2.3,2.

Representing Information 0 1 0 Bit Juggling 1 1 - Representing information using bits - Number representations 1 - Some other bits 0 0 - Chapters 1 and 2.3,2.4 Motivations Computers Process Information

### Fundamentals of Programming Session 2

Fundamentals of Programming Session 2 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Fall 2013 Sharif University of Technology Outlines Programming Language Binary numbers Addition Subtraction

### Time (self-scheduled): Location Schedule Your Exam: What to bring:

ECE 120 Midterm 1B HKN Review Session Time (self-scheduled): Between Wednesday, September 27 and Friday, September 29, 2017 Location: 57 Grainger Engineering Library (in the basement on the east side)

### Basic Operations jgrasp debugger Writing Programs & Checkstyle

Basic Operations jgrasp debugger Writing Programs & Checkstyle Suppose you wanted to write a computer game to play "Rock, Paper, Scissors". How many combinations are there? Is there a tricky way to represent

### ECE 2030D Computer Engineering Spring problems, 5 pages Exam Two 8 March 2012

Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have a question, raise your hand and I will come to you. Please work the exam in pencil and do not separate

### CS 241 Data Organization Binary

CS 241 Data Organization Binary Brooke Chenoweth University of New Mexico Fall 2017 Combinations and Permutations In English we use the word combination loosely, without thinking if the order of things

### Data Representation 1

1 Data Representation Outline Binary Numbers Adding Binary Numbers Negative Integers Other Operations with Binary Numbers Floating Point Numbers Character Representation Image Representation Sound Representation

### ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two Solutions 26 February 2014

Problem 1 (4 parts, 21 points) Encoders and Pass Gates Part A (8 points) Suppose the circuit below has the following input priority: I 1 > I 3 > I 0 > I 2. Complete the truth table by filling in the input

### Computer Architecture and Organization

3-1 Chapter 3 - Arithmetic Computer Architecture and Organization Miles Murdocca and Vincent Heuring Chapter 3 Arithmetic 3-2 Chapter 3 - Arithmetic Chapter Contents 3.1 Fixed Point Addition and Subtraction

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

The type of all data used in a C++ program must be specified A data type is a description of the data being represented That is, a set of possible values and a set of operations on those values There are

### Exercise: Using Numbers

Exercise: Using Numbers Problem: You are a spy going into an evil party to find the super-secret code phrase (made up of letters and spaces), which you will immediately send via text message to your team

### PYTHON- AN INNOVATION

PYTHON- AN INNOVATION As per CBSE curriculum Class 11 Chapter- 2 By- Neha Tyagi PGT (CS) KV 5 Jaipur(II Shift) Jaipur Region Python Introduction In order to provide an input, process it and to receive

### Under the Hood: Data Representation. Computer Science 104 Lecture 2

Under the Hood: Data Representation Computer Science 104 Lecture 2 Admin Piazza, Sakai Up Everyone should have access Homework 1 Posted Due Feb 6 PDF or Plain Text Only: No Word or RTF Recommended: Learn

### Work relative to other classes

Work relative to other classes 1 Hours/week on projects 2 C BOOTCAMP DAY 1 CS3600, Northeastern University Slides adapted from Anandha Gopalan s CS132 course at Univ. of Pittsburgh Overview C: A language

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

Digital Logic 1 Data Representations 1.1 The Binary System 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. The system we

### Final Labs and Tutors

ICT106 Fundamentals of Computer Systems - Topic 2 REPRESENTATION AND STORAGE OF INFORMATION Reading: Linux Assembly Programming Language, Ch 2.4-2.9 and 3.6-3.8 Final Labs and Tutors Venue and time South

### 2/5/2018. Expressions are Used to Perform Calculations. ECE 220: Computer Systems & Programming. Our Class Focuses on Four Types of Operator in C

University of Illinois at Urbana-Champaign Dept. of Electrical and Computer Engineering ECE 220: Computer Systems & Programming Expressions and Operators in C (Partially a Review) Expressions are Used

### Character Set. The character set of C represents alphabet, digit or any symbol used to represent information. Digits 0, 1, 2, 3, 9

Character Set The character set of C represents alphabet, digit or any symbol used to represent information. Types Uppercase Alphabets Lowercase Alphabets Character Set A, B, C, Y, Z a, b, c, y, z Digits