C Puzzles! Taken from old exams. Integers Sep 3, Encoding Integers Unsigned. Encoding Example (Cont.) The course that gives CMU its Zip!
|
|
- Dorthy Miles
- 5 years ago
- Views:
Transcription
1 15-13 The corse that gies CMU its Zip! Topics class3.ppt Integers Sep 3,! Nmeric Encodings " Unsigned & Two s complement! Programming Implications " C promotion rles! Basic operations " Addition, negation, mltiplication! Programming Implications " Conseqences of oerflow " Using shifts to perform power-of- mltiply/diide F C Pzzles! Taen from old exams! Assme machine with 3 bit word size, two s complement integers! For each of the following C expressions, either: " Arge that is tre for all argment ales " Gie example where not tre Initialization int x = foo(); int y = bar(); nsigned x = x; nsigned y = y; x <! ((x*) < ) x >= x & 7 == 7! (x<<3) < x > -1 x > y! -x < -y x * x >= x > && y >! x + y > x >=! -x <= x <=! -x >= 15-13, F Encoding Integers Unsigned Two s Complement w"1 # BU(X) = x i! i i= w! # BT(X) =!x w!1 " w!1 + x i " i i= Encoding Example (Cont.) x = 1513: y = -1513: Weight short int x = 1513; short int y = -1513;! C short bytes long Sign Bit DecimalHexBinaryx Sign Bit! For s complement, most significant bit indicates sign " for nonnegatie " 1 for negatie , F 15-13, F
2 Nmeric Ranges Vales for Different Word Sizes Unsigned Vales! UMin =! UMax = w Vales for W = 1 DecimalHexBinaryUMax Two s s Complement Vales! TMin = w 1 1! TMax = w Other Vales! Mins W13 Obserations! TMin = TMax + 1 " Asymmetric range! UMax = * TMax + 1 C Programming!!#inclde <limits.h> " K&R App. B11! Declares constants, e.g., "!ULONG_MAX "!LONG_MAX "!LONG_MIN! Vales platform-specific , F 15-13, F Unsigned & Signed Nmeric Vales X BU(X) BT(X) Eqialence! Same encodings for nonnegatie ales Uniqeness! Eery bit pattern represents niqe integer ale! Each representable integer has niqe bit encoding! Can Inert Mappings! UB(x) = BU -1 (x) " Bit pattern for nsigned integer 1! TB(x) = BT -1 (x) 15 1 " Bit pattern for two s comp 7 integer 15-13, F Casting Signed to Unsigned C Allows Conersions from Signed to Unsigned short int x = 1513; nsigned short int x = (nsigned short) x; short int y = -1513; nsigned short int y = (nsigned short) y; Reslting Vale! No change in bit representation! Nonnegatie ales nchanged " x = 1513! Negatie ales change into (large) positie ales " y = , F
3 Relation between Signed & Unsigned Relation Between Signed & Unsigned Weight Two s Complement x TB TU X BU Unsigned x Maintain Same Bit Pattern - w 1 x x w 1 w 1 = * w 1 = w x = " x x! # $ x + w x <! y = y + * 37 = y , F , F Signed s. Unsigned in C Constants! By defalt are considered to be signed integers! Unsigned if hae U as sffix U, 99759U Casting! Explicit casting between signed & nsigned same as UT and TU int tx, ty; nsigned x, y; tx = (int) x; y = (nsigned) ty;! Implicit casting also occrs ia assignments and procedre calls tx = x; y = ty; , F Casting Srprises Expression Ealation! If mix nsigned and signed in single expression, signed ales implicitly cast to nsigned! Inclding comparison operations <, >, ==, <=, >=! Examples for W = 3 Constant 1 Constant Relation Ealation U == nsigned -1 < signed -1 U > nsigned > signed 1737U -173 < nsigned -1 - > signed (nsigned) -1 - > nsigned U < nsigned 1737 (int) 173U > signed , F
4 Explanation of Casting Srprises Sign Extension s s Comp. " Unsigned! Ordering Inersion! Negatie " Big Positie UMax UMax 1 Tas:! Gien w-bit signed integer x! Conert it to w+-bit integer with same ale TMax TMax + 1 TMax Unsigned Range Rle:! Mae copies of sign bit:! X # = x w 1,, x w 1, x w 1, x w,, x s Comp. Range 1 copies of MSB X w TMin , F X # , F w Sign Extension Example short int x = 1513; int ix = (int) x; short int y = -1513; int iy = (int) y; Decimal Hex Binary x B D ix B D y C iy FF FF C ! Conerting from smaller to larger integer data type! C atomatically performs sign extension Jstification For Sign Extension Proe Correctness by Indction on! Indction Step: extending by single bit maintains ale X w - X # - + w+1! Key obseration: w 1 = w + w 1! Loo at weight of pper bits: X w 1 x w , F X # w x w 1 + w 1 x w 1 = w 1 x w , F
5 Why Shold I Use Unsigned? Don t Use Jst Becase Nmber Nonzero! C compilers on some machines generate less efficient code nsigned i; for (i = 1; i < cnt; i++) a[i] += a[i-1];! Easy to mae mistaes for (i = cnt-; i >= ; i--) a[i] += a[i+1]; Do Use When Performing Modlar Arithmetic! Mltiprecision arithmetic! Other esoteric stff Do Use When Need Extra Bit s s Worth of Range! Woring right p to limit of word size , F Negating with Complement & Increment Claim: Following Holds for s s Complement ~x + 1 == -x Complement! Obseration: ~x + x == == -1 Increment! ~x + x + (-x + 1) == -1 + (-x + 1)! ~x + 1 == -x Warning: Be catios treating int s as integers , F! OK here + x ~x Comp. & Incr. Examples x = 1513 lhexbinaryx Unsigned Addition Operands: w bits Tre Sm: w+1 bits + + DecimalHexBinary ~ Discard Carry: w bits UAdd w (, ) Standard Addition Fnction! Ignores carry otpt Implements Modlar Arithmetic s = UAdd w (, ) = + mod w UAdd w (,) = # + $ % +! w + < w + " w , F 15-13, F
6 Visalizing Integer Addition Visalizing Unsigned Addition Integer Addition! -bit integers,! Compte tre sm Add (, )! Vales increase linearly with and! Forms planar srface Add (, ) Integer Addition Wraps Arond! If tre sm " w! At most once Tre Sm w+1 w Oerflow Modlar Sm Oerflow UAdd (, ) , F 15-13, F Mathematical Properties Modlar Addition Forms an Abelian Grop! Closed nder addition!!$!uadd w (, )!! $! w 1! Commtatie UAdd w (, )!!=!! UAdd w (, )! Associatie UAdd w (t, UAdd w (, ))!!=!! UAdd w (UAdd w (t, ), )! is additie identity UAdd w (, )!!=!!! Eery element has additie inerse " Let UComp w ( )!!=! w UAdd w (, UComp w ( ))!!=!! Two s Complement Addition Operands: w bits Tre Sm: w+1 bits TAdd and UAdd hae Identical Bit-Leel Behaior! Signed s. nsigned addition in C: int s, t,, ; s = (int) ((nsigned) + (nsigned) ); t = +! Will gie s == t + + Discard Carry: w bits TAdd w (, ) , F 15-13, F
7 Characterizing TAdd Fnctionality! Tre sm reqires w+1 bits! Drop off MSB! Treat remaining bits as s comp. integer TAdd(, ) > < < > NegOer PosOer TAdd w (,) = Tre Sm w 1 w 1 w , F w # + + w!1 % $ + % & +! w!1 PosOer NegOer TAdd Reslt < TMin (NegOer) w TMin w " + " TMax w TMax w < + (PosOer) Visalizing s Comp. Addition Vales! -bit two s comp.! Range from - to +7 Wraps Arond! If sm % w 1 " Becomes negatie " At most once! If sm < w 1 " Becomes positie " At most once NegOer TAdd (, ) 15-13, F PosOer Detecting s Comp. Oerflow Tas Claim! Gien s = TAdd w (, )! Determine if s = Add w (, )! Example int s,, ; s = + ;! Oerflow iff either:, <, s % (NegOer), %, s < (PosOer) w 1 w 1 of = (< == <) && (<!= s<); PosOer NegOer Mathematical Properties of TAdd Isomorphic Algebra to UAdd! TAdd w (, ) = UT(UAdd w (TU( ), TU())) " Since both hae identical bit patterns Two s s Complement Under TAdd Forms a Grop! Closed, Commtatie, Associatie, is additie identity! Eery element has additie inerse Let TComp w ( )!!=! UT(UComp w (TU( )) TAdd w (, TComp w ( ))!!=!! TComp w () = #! " TMin w $ % TMin w = TMin w , F 15-13, F
8 Mltiplication Compting Exact Prodct of w-bit nmbers x, y! Either signed or nsigned Ranges! Unsigned:! x * y! ( w 1) = w w " Up to w bits! Two s complement min: x * y " ( w 1 )*( w 1 1) = w + w 1 " Up to w 1 bits! Two s complement max: x * y! ( w 1 ) = w " Up to w bits, bt only for (TMin w ) Maintaining Exact Reslts! Wold need to eep expanding word size with each prodct compted! Done in software by arbitrary precision arithmetic pacages Unsigned Mltiplication in C Operands: w bits Tre Prodct: *w bits Discard w bits: w bits UMlt w (, ) Standard Mltiplication Fnction! Ignores high order w bits Implements Modlar Arithmetic UMlt w (, ) = mod w * , F , F Unsigned s. Signed Mltiplication Unsigned Mltiplication nsigned x = (nsigned) x; nsigned y = (nsigned) y; nsigned p = x * y! Trncates prodct to w-bit nmber p = UMlt w (x, y)! Modlar arithmetic: p = x & y mod w Two s s Complement Mltiplication int x, y; int p = x * y;! Compte exact prodct of two w-bit nmbers x, y! Trncate reslt to w-bit nmber p = TMlt w (x, y) Unsigned s. Signed Mltiplication Unsigned Mltiplication nsigned x = (nsigned) x; nsigned y = (nsigned) y; nsigned p = x * y Two s s Complement Mltiplication int x, y; Relation int p = x * y;! Signed mltiplication gies same bit-leel reslt as nsigned! p == (nsigned) p , F , F
9 Power-of- Mltiply with Shift Operation! << gies *! Both signed and nsigned Operands: w bits Tre Prodct: w+ bits Examples Discard bits: w bits UMlt w (, )! << 3 == *! << 5 - << 3 == * 1! Most machines shift and add mch faster than mltiply " Compiler generates this code atomatically , F * TMlt w (, ) Unsigned Power-of- Diide with Shift Qotient of Unsigned by Power of! >> gies ) / *! Uses logical shift Operands: Diision: Reslt: / / 1 DiisionComptedHexBinaryx x > , F. ) / * Binary Point Signed Power-of- Diide with Shift Correct Power-of- Diide Qotient of Signed by Power of! x >> gies ) x / *! Uses arithmetic shift! Ronds wrong direction when < x Operands: / 1 Diision: Reslt: x / RondDown(x / ) DiisionComptedHexBinaryy. Binary Point y Qotient of Negatie Nmber by Power of! Want ' x / ( (Rond Toward )! Compte as ) (x+ -1)/ * " In C: (x + (1<<)-1) >> " Biases diidend toward Case 1: No ronding Diidend: Diisor: / ' / ( Binary Point , F Biasing has no effect , F
10 Correct Power-of- Diide (Cont.) Case : Ronding Diidend: Diisor: / x ' x / ( Incremented by 1 Biasing adds 1 to final reslt Incremented by 1 Binary Point Properties of Unsigned Arithmetic Unsigned Mltiplication with Addition Forms Commtatie Ring! Addition is commtatie grop! Closed nder mltiplication!!$!umlt w (, )!!$! w 1! Mltiplication Commtatie UMlt w (, )!!=!! UMlt w (, )! Mltiplication is Associatie UMlt w (t, UMlt w (, ))!!=!! UMlt w (UMlt w (t, ), )! 1 is mltiplicatie identity UMlt w (, 1)!!=!!! Mltiplication distribtes oer addtion UMlt w (t, UAdd w (, ))!!=!! UAdd w (UMlt w (t, ), UMlt w (t, )) , F , F Properties of Two s Comp. Arithmetic Isomorphic Algebras! Unsigned mltiplication and addition " Trncating to w bits! Two s complement mltiplication and addition " Trncating to w bits Both Form Rings! Isomorphic to ring of integers mod w Comparison to Integer Arithmetic! Both are rings! Integers obey ordering properties, e.g., >! + > >, >! >! These properties are not obeyed by two s comp. arithmetic C Pzzle Answers! Assme machine with 3 bit word size, two s comp. integers! TMin maes a good conterexample in many cases # x <! ((x*) < ) False: TMin # x >= Tre: = UMin # x & 7 == 7! (x<<3) < Tre: x 1 = 1 # x > -1 False: # x > y! -x < -y False: -1, TMin # x * x >= False: 3 # x > && y >! x + y > False: TMax, TMax # x >=! -x <= Tre: TMax < # x <=! -x >= False: TMin TMax + 1 == TMin * 3 == -13 (1-bit words) 15-13, F 15-13, F
C Puzzles The course that gives CMU its Zip! Integer Arithmetic Operations Jan. 25, Unsigned Addition. Visualizing Integer Addition
1513 The corse that gies CMU its Zip! Integer Arithmetic Operations Jan. 5, 1 Topics Basic operations Addition, negation, mltiplication Programming Implications Conseqences of oerflow Using shifts to perform
More informationPage # CISC360. Integers Sep 11, Encoding Integers Unsigned. Encoding Example (Cont.) Topics. Twoʼs Complement. Sign Bit
Topics CISC3 Integers Sep 11, 28 Nmeric Encodings Unsigned & Twoʼs complement Programming Implications C promotion rles Basic operations Addition, negation, mltiplication Programming Implications Conseqences
More informationIntegers Sep 3, 2002
15-213 The course that gives CMU its Zip! Topics Numeric Encodings Unsigned & Two s complement Programming Implications C promotion rules Basic operations Integers Sep 3, 2002 Addition, negation, multiplication
More informationPage 1 CISC360. Encoding Integers Unsigned. Integers Sep 8, Numeric Ranges. Encoding Example (Cont.)
CISC3 Integers Sep, 9 Encoding Integers Unsigned w 1 BU(X) = x i i i= short int x = 1513; short int y = -1513; Twoʼs Complement w BT(X) = x w 1 w 1 + x i i i= Sign Bit Decimal Hex Binary x 1513 3B D 11111
More informationSystems 1. Integers. Unsigned & Twoʼs complement. Addition, negation, multiplication
Systems 1 Integers Topics Numeric Encodings Unsigned & Twoʼs complement Programming Implications C promotion rules Basic operations Addition, negation, multiplication Programming Implications Consequences
More informationIntegers. Dr. Steve Goddard Giving credit where credit is due
CSCE 23J Computer Organization Integers Dr. Steve Goddard goddard@cse.unl.edu http://cse.unl.edu/~goddard/courses/csce23j Giving credit where credit is due Most of slides for this lecture are based on
More informationBits, Bytes, and Integers. Bits, Bytes, and Integers. The Decimal System and Bases. Everything is bits. Converting from Decimal to Binary
with contribtions from Dr. Bin Ren, College of William & Mary Addition, negation, mltiplication, shifting 1 Everything is bits The Decimal System and Bases Each bit is or 1 By encoding/interpreting sets
More informationBits, Bytes, and Integer
19.3 Compter Architectre Spring 1 Bits, Bytes, and Integers Nmber Representations Bits, Bytes, and Integer Representing information as bits Bit-level maniplations Integers Representation: nsigned and signed
More informationTopics of this Slideset. CS429: Computer Organization and Architecture. Encoding Integers: Unsigned. C Puzzles. Integers
Topics of this Slideset CS429: Computer Organization and Architecture Dr. Bill Young Department of Computer Science University of Texas at Austin Last updated: July 5, 2018 at 11:55 Numeric Encodings:
More informationCS429: Computer Organization and Architecture
CS429: Computer Organization and Architecture Dr. Bill Young Department of Computer Science University of Texas at Austin Last updated: July 5, 2018 at 11:55 CS429 Slideset 3: 1 Topics of this Slideset
More informationIntegers. Today. Next time. ! Numeric Encodings! Programming Implications! Basic operations. ! Floats
Integers Today! Numeric Encodings! Programming Implications! Basic operations! Programming Implications Next time! Floats Fabián E. Bustamante, 2007 Integers in C! C supports several integral data types
More informationInteger Arithmetic. CS 347 Lecture 03. January 20, 1998
Integer Arithmetic CS 347 Lecture 03 January 20, 1998 Topics Numeric Encodings Unsigned & Two s complement Programming Implications C promotion rules Consequences of overflow Basic operations Addition,
More informationSystems Programming and Computer Architecture ( )
Systems Group Department of Computer Science ETH Zürich Systems Programming and Computer Architecture (252-0061-00) Timothy Roscoe Herbstsemester 2016 1 3: Integers in C Computer Architecture and Systems
More informationBits, Bytes, and Integers August 26, 2009
15-213 The Class That Gives CMU Its Zip! Bits, Bytes, and Integers August 26, 2009 Topics Representing information as bits Bit-level manipulations Boolean algebra Expressing in C Representations of Integers
More informationComputer Systems CEN591(502) Fall 2011
Computer Systems CEN591(502) Fall 2011 Sandeep K. S. Gupta Arizona State University 4 th lecture Data representation in computer systems (Slides adapted from CSAPP book) Announcements Programming assignment
More informationToday: Bits, Bytes, and Integers. Bits, Bytes, and Integers. For example, can count in binary. Everything is bits. Encoding Byte Values
Today: Bits, Bytes, and Integers Representing information as bits Bits, Bytes, and Integers CSci : Machine Architectre and Organization September th-9th, Yor instrctor: Stephen McCamant Bit-level maniplations
More informationCS 33. Data Representation, Part 2. CS33 Intro to Computer Systems VII 1 Copyright 2018 Thomas W. Doeppner. All rights reserved.
CS 33 Data Representation, Part 2 CS33 Intro to Computer Systems VII 1 Copyright 2018 Thomas W. Doeppner. All rights reserved. Signed Integers Two s complement b w-1 = 0 Þ non-negative number value = b
More informationBits, Bytes, and Integers. Data Representa+on: Base- 2 number representa+on. Binary Representa+ons. Encoding Byte Values. Example Data Representa+ons
Bits, Bytes, and Data Representa+on: Bits, Bytes, and CSci 1 - Machine Architectre and Organiza+on Professor Pen- Chng Yew Bit- level manipla+ons Representa9on: nsigned and signed Expanding, trnca9ng Addi9on,
More informationBits, Bytes, and Integers
Bits, Bytes, and Integers with contributions from Dr. Bin Ren, College of William & Mary 1 Bits, Bytes, and Integers Representing information as bits Bit-level manipulations Integers Representation: unsigned
More informationCS 33. Data Representation, Part 2. CS33 Intro to Computer Systems VIII 1 Copyright 2017 Thomas W. Doeppner. All rights reserved.
CS 33 Data Representation, Part 2 CS33 Intro to Computer Systems VIII 1 Copyright 2017 Thomas W. Doeppner. All rights reserved. Numeric Ranges Unsigned Values UMin = 0 000 0 UMax = 2 w 1 111 1 Two s Complement
More informationCarnegie Mellon. Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition
Carnegie Mellon 1 Bits, Bytes and Integers Part 1 15-213/18-213/15-513: Introduction to Computer Systems 2 nd Lecture, Aug. 31, 2017 Today s Instructor: Randy Bryant 2 Announcements Recitations are on
More informationRepresenta7on of integers: unsigned and signed Conversion, cas7ng Expanding, trunca7ng Addi7on, nega7on, mul7plica7on, shiaing
Today s Topics Representa7on of integers: unsigned and signed Conversion, cas7ng Expanding, trunca7ng Addi7on, nega7on, mul7plica7on, shiaing CSE351 Inaugural Edi7on Spring 2010 1 Encoding Integers C short
More informationCS140 Lecture 08: Data Representation: Bits and Ints. John Magee 13 February 2017
CS140 Lecture 08: Data Representation: Bits and Ints John Magee 13 February 2017 Material From Computer Systems: A Programmer's Perspective, 3/E (CS:APP3e) Randal E. Bryant and David R. O'Hallaron, Carnegie
More informationRepresenting and Manipulating Integers. Jo, Heeseung
Representing and Manipulating Integers Jo, Heeseung Unsigned Integers Encoding unsigned integers B [ bw 1, bw 2,..., b0 ] x = 0000 0111 1101 0011 2 D( B) w 1 b i i 0 2 i D(x) = 2 10 + 2 9 + 2 8 + 2 7 +
More informationCsci 2021 Class Web Pages. Data Representa?on: Bits, Bytes, and Integers. Binary Representa?ons. Bits, Bytes, and Integers
Csci 1 Class Web Pages Departmental Class Web Page: Pblic access withot login Corse syllabs, schedle, lectre notes, other sefl info h7p://www- sers.cselabs.mn.ed/classes/spring- 1/csci1/ Yo shold read
More informationBits, Bytes and Integers Part 1
Bits, Bytes and Integers Part 1 15-213/18-213/15-513: Introduction to Computer Systems 2 nd Lecture, Jan. 18, 2018 Instructors: Franz Franchetti Seth Copen Goldstein Brian Railing 1 Announcements Waitlist
More informationBits, Bytes, and Integers Part 2
Bits, Bytes, and Integers Part 2 15-213: Introduction to Computer Systems 3 rd Lecture, Jan. 23, 2018 Instructors: Franz Franchetti, Seth Copen Goldstein, Brian Railing 1 First Assignment: Data Lab Due:
More informationLecture 5-6: Bits, Bytes, and Integers
CSCI-UA.0201-003 Computer Systems Organization Lecture 5-6: Bits, Bytes, and Integers Mohamed Zahran (aka Z) mzahran@cs.nyu.edu http://www.mzahran.com Slides adapted from: Jinyang Li Bryant and O Hallaron
More informationJin-Soo Kim Systems Software & Architecture Lab. Seoul National University. Integers. Spring 2019
Jin-Soo Kim (jinsoo.kim@snu.ac.kr) Systems Software & Architecture Lab. Seoul National University Integers Spring 2019 4190.308: Computer Architecture Spring 2019 Jin-Soo Kim (jinsoo.kim@snu.ac.kr) 2 A
More informationInteger Encoding and Manipulation
CSE 2421: Systems I Low-Level Programming and Computer Organization Integer Encoding and Manipulation Presentation D Study: Bryant Chapter 2.1 2.3 Gojko Babić 01-24-2018 Unsigned & Signed Integer Encoding
More informationBut first, encode deck of cards. Integer Representation. Two possible representations. Two better representations WELLESLEY CS 240 9/8/15
Integer Representation Representation of integers: unsigned and signed Sign extension Arithmetic and shifting Casting But first, encode deck of cards. cards in suits How do we encode suits, face cards?
More informationBITS, BYTES, AND INTEGERS
BITS, BYTES, AND INTEGERS CS 045 Computer Organization and Architecture Prof. Donald J. Patterson Adapted from Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition ORIGINS
More informationRepresenting Integers. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University
Representing Integers Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Unsigned Integers Encoding unsigned integers B [ bw 1, bw2,..., b0 ] x = 0000
More informationBits, Bytes, and Integers
Bits, Bytes, and Integers B&O Readings: 2.1-2.3 CSE 361: Introduc=on to Systems So@ware Instructor: I- Ting Angelina Le e Note: these slides were originally created by Markus Püschel at Carnegie Mellon
More informationRepresenting Integers
Representing Integers Jinkyu Jeong (jinkyu@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu SSE2030: Introduction to Computer Systems, Spring 2018, Jinkyu Jeong (jinkyu@skku.edu)
More informationRepresenting and Manipulating Integers Part I
Representing and Manipulating Integers Part I Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Introduction The advent of the digital age Analog
More informationArithmetic 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
More informationFoundations of Computer Systems
18-600 Foundations of Computer Systems Lecture 3: Bits, Bytes, and Integers September 6, 2017 Required Reading Assignment: Chapter 2 of CS:APP (3 rd edition) by Randy Bryant & Dave O Hallaron Assignments
More informationCS 270: Computer Organization. Integer Arithmetic Operations
CS 270: Computer Organization Integer Arithmetic Operations Instructor: Professor Stephen P. Carl Unsigned Addition Operands: w bits True Sum: w+1 bits u + v u + v Discard Carry UAdd w (u, v) Standard
More informationComputer Organization: A Programmer's Perspective
A Programmer's Perspective Bits, Bytes, Nibbles, Words and Strings Gal A. Kaminka galk@cs.biu.ac.il Topics Why bits? Why 0/1? Basic terms: Bits, Bytes, Nibbles, Words Representing information as bits Characters
More informationArithmetic and Bitwise Operations on Binary Data
Arithmetic and Bitwise Operations on Binary Data CSCI 224 / ECE 317: Computer Architecture Instructor: Prof. Jason Fritts Slides adapted from Bryant & O Hallaron s slides 1 Boolean Algebra Developed by
More informationManipulating Integers
Manipulating Integers Jinkyu Jeong (jinkyu@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu SSE2030: Introduction to Computer Systems, Spring 2018, Jinkyu Jeong (jinkyu@skku.edu)
More informationBits, Bytes, and Integers
Bits, Bytes, and Integers CENG331 - Computer Organization Instructors: Murat Manguoglu (Section 1) Adapted from slides of the textbook: http://csapp.cs.cmu.edu/ Hello World! What happens under the hood?
More informationInts and Floating Point
Ints and Floating Point CSE 351 Winter 2017 http://xkcd.com/899/ Administriia Lab 1 due Friday How is it going? HW 1 out today Numerical representation and executable inspection 2 Using Shifts and Masks
More informationIntegers II. CSE 351 Autumn Instructor: Justin Hsia
Integers II CSE 351 Autumn 2016 Instructor: Justin Hsia Teaching Assistants: Chris Ma Hunter Zahn John Kaltenbach Kevin Bi Sachin Mehta Suraj Bhat Thomas Neuman Waylon Huang Xi Liu Yufang Sun http://xkcd.com/571/
More informationICS Instructor: Aleksandar Kuzmanovic TA: Ionut Trestian Recitation 2
ICS 2008 Instructor: Aleksandar Kuzmanovic TA: Ionut Trestian Recitation 2 Data Representations Sizes of C Objects (in Bytes) C Data Type Compaq Alpha Typical 32-bit Intel IA32 int 4 4 4 long int 8 4 4
More informationIntegers II. CSE 351 Autumn Instructor: Justin Hsia
Integers II CSE 351 Autumn 2017 Instructor: Justin Hsia Teaching Assistants: Lucas Wotton Michael Zhang Parker DeWilde Ryan Wong Sam Gehman Sam Wolfson Savanna Yee Vinny Palaniappan http://xkcd.com/557/
More informationBits, Bytes and Integers
Bits, Bytes and Integers Computer Systems Organization (Spring 2016) CSCI-UA 201, Section 2 Instructor: Joanna Klukowska Slides adapted from Randal E. Bryant and David R. O Hallaron (CMU) Mohamed Zahran
More informationIntegers II. CSE 351 Autumn 2018
Integers II CSE 351 Autumn 2018 Instructor: Teaching Assistants: Justin Hsia Akshat Aggarwal An Wang Andrew Hu Brian Dai Britt Henderson James Shin Kevin Bi Kory Watson Riley Germundson Sophie Tian Teagan
More informationLemma 1 Let the components of, Suppose. Trees. A tree is a graph which is. (a) Connected and. (b) has no cycles (acyclic). (b)
Trees Lemma Let the components of ppose "! be (a) $&%('*)+ - )+ / A tree is a graph which is (b) 0 %(')+ - 3)+ / 6 (a) (a) Connected and (b) has no cycles (acyclic) (b) roof Eery path 8 in which is not
More informationBits and Bytes: Data Presentation Mohamed Zahran (aka Z)
CSCI-UA.0201 Computer Systems Organization Bits and Bytes: Data Presentation Mohamed Zahran (aka Z) mzahran@cs.nyu.edu http://www.mzahran.com Some slides adapted and modified from: Clark Barrett Jinyang
More informationFloating Point Puzzles The course that gives CMU its Zip! Floating Point Jan 22, IEEE Floating Point. Fractional Binary Numbers.
class04.ppt 15-213 The course that gives CMU its Zip! Topics Floating Point Jan 22, 2004 IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties Floating Point Puzzles For
More informationBitwise Data Manipulation. Bitwise operations More on integers
Bitwise Data Manipulation Bitwise operations More on integers bitwise operators ex Bitwise operators on fixed-width bit vectors. AND & OR XOR ^ NOT ~ 01101001 & 01010101 01000001 01101001 01010101 01101001
More informationInteger Representation
Integer Representation Representation of integers: unsigned and signed Modular arithmetic and overflow Sign extension Shifting and arithmetic Multiplication Casting 1 Fixed- width integer encodings Unsigned
More informationf x y z ds f P S (,, ) lim ( ) ds f P S S S.
4.7 rface Integral We diide srface into patches patch, mltiply by the area with area, and form the sm n n i j f P ( ). We ealate f at a point P, in each Then we take the limit as the patch size approaches
More informationPOWER-OF-2 BOUNDARIES
Warren.3.fm Page 5 Monday, Jne 17, 5:6 PM CHAPTER 3 POWER-OF- BOUNDARIES 3 1 Ronding Up/Down to a Mltiple of a Known Power of Ronding an nsigned integer down to, for eample, the net smaller mltiple of
More informationFloating Point January 24, 2008
15-213 The course that gives CMU its Zip! Floating Point January 24, 2008 Topics IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties class04.ppt 15-213, S 08 Floating
More informationCS367 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,
More informationArithmetic Operators. Portability: Printing Numbers
Arithmetic Operators Normal binary arithmetic operators: + - * / Modulus or remainder operator: % x%y is the remainder when x is divided by y well defined only when x > 0 and y > 0 Unary operators: - +
More informationSystems I. Floating Point. Topics IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties
Systems I Floating Point Topics IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties IEEE Floating Point IEEE Standard 754 Established in 1985 as uniform standard for
More informationSimple Data Types in C. Alan L. Cox
Simple Data Types in C Alan L. Cox alc@rice.edu Objectives Be able to explain to others what a data type is Be able to use basic data types in C programs Be able to see the inaccuracies and limitations
More informationThe course that gives CMU its Zip! Floating Point Arithmetic Feb 17, 2000
15-213 The course that gives CMU its Zip! Floating Point Arithmetic Feb 17, 2000 Topics IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties IA32 floating point Floating
More informationFloating Point Puzzles. Lecture 3B Floating Point. IEEE Floating Point. Fractional Binary Numbers. Topics. IEEE Standard 754
Floating Point Puzzles Topics Lecture 3B Floating Point IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties For each of the following C expressions, either: Argue that
More informationChapter 2 Float Point Arithmetic. Real Numbers in Decimal Notation. Real Numbers in Decimal Notation
Chapter 2 Float Point Arithmetic Topics IEEE Floating Point Standard Fractional Binary Numbers Rounding Floating Point Operations Mathematical properties Real Numbers in Decimal Notation Representation
More informationSystem Programming CISC 360. Floating Point September 16, 2008
System Programming CISC 360 Floating Point September 16, 2008 Topics IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties Powerpoint Lecture Notes for Computer Systems:
More informationGiving credit where credit is due
CSCE 230J Computer Organization Floating Point Dr. Steve Goddard goddard@cse.unl.edu http://cse.unl.edu/~goddard/courses/csce230j Giving credit where credit is due Most of slides for this lecture are based
More informationCOMP2611: 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
More informationGiving credit where credit is due
JDEP 284H Foundations of Computer Systems Floating Point Dr. Steve Goddard goddard@cse.unl.edu Giving credit where credit is due Most of slides for this lecture are based on slides created by Drs. Bryant
More informationDigital Image Processing Chapter 5: Image Restoration
Digital Image Processing Chapter 5: Image Restoration Concept of Image Restoration Image restoration is to restore a degraded image back to the original image while image enhancement is to maniplate the
More informationThe extra single-cycle adders
lticycle Datapath As an added bons, we can eliminate some of the etra hardware from the single-cycle path. We will restrict orselves to sing each fnctional nit once per cycle, jst like before. Bt since
More informationFloating Point Puzzles. Lecture 3B Floating Point. IEEE Floating Point. Fractional Binary Numbers. Topics. IEEE Standard 754
Floating Point Puzzles Topics Lecture 3B Floating Point IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties For each of the following C expressions, either: Argue that
More informationProgramming in C++ 5. Integral data types
Programming in C++ 5. Integral data types! Introduction! Type int! Integer multiplication & division! Increment & decrement operators! Associativity & precedence of operators! Some common operators! Long
More informationThe final datapath. M u x. Add. 4 Add. Shift left 2. PCSrc. RegWrite. MemToR. MemWrite. Read data 1 I [25-21] Instruction. Read. register 1 Read.
The final path PC 4 Add Reg Shift left 2 Add PCSrc Instrction [3-] Instrction I [25-2] I [2-6] I [5 - ] register register 2 register 2 Registers ALU Zero Reslt ALUOp em Data emtor RegDst ALUSrc em I [5
More informationReview. How to represent real numbers
PCWrite PC IorD Review ALUSrcA emread Address Write data emory emwrite em Data IRWrite [3-26] [25-2] [2-6] [5-] [5-] RegDst Read register Read register 2 Write register Write data RegWrite Read data Read
More informationCIS133J. Working with Numbers in Java
CIS133J Working with Numbers in Java Contents: Using variables with integral numbers Using variables with floating point numbers How to declare integral variables How to declare floating point variables
More informationCSE 351 Midterm - Winter 2017
CSE 351 Midterm - Winter 2017 February 08, 2017 Please read through the entire examination first, and make sure you write your name and NetID on all pages! We designed this exam so that it can be completed
More informationReconstructing Generalized Staircase Polygons with Uniform Step Length
Jornal of Graph Algorithms and Applications http://jgaa.info/ ol. 22, no. 3, pp. 431 459 (2018) DOI: 10.7155/jgaa.00466 Reconstrcting Generalized Staircase Polygons with Uniform Step Length Nodari Sitchinaa
More informationInteger Representation Floating point Representation Other data types
Chapter 2 Bits, Data Types & Operations Integer Representation Floating point Representation Other data types Why do Computers use Base 2? Base 10 Number Representation Natural representation for human
More informationSemester Transition Point. EE 109 Unit 11 Binary Arithmetic. Binary Arithmetic ARITHMETIC
1 2 Semester Transition Point EE 109 Unit 11 Binary Arithmetic At this point we are going to start to transition in our class to look more at the hardware organization and the low-level software that is
More informationCS:APP Web Aside DATA:TNEG: Bit-Level Representation of Two s Complement Negation
CS:APP Web Aside DATA:TNEG: Bit-Level Representation of Two s Complement Negation Randal E. Bryant David R. O Hallaron August 27, 2016 Notice The material in this document is supplementary material to
More informationCS429: Computer Organization and Architecture
CS429: Computer Organization and Architecture Dr. Bill Young Department of Computer Sciences University of Texas at Austin Last updated: September 18, 2017 at 12:48 CS429 Slideset 4: 1 Topics of this Slideset
More informationObject Pose from a Single Image
Object Pose from a Single Image How Do We See Objects in Depth? Stereo Use differences between images in or left and right eye How mch is this difference for a car at 00 m? Moe or head sideways Or, the
More informationCAPL Scripting Quickstart
CAPL Scripting Qickstart CAPL (Commnication Access Programming Langage) For CANalyzer and CANoe V1.01 2015-12-03 Agenda Important information before getting started 3 Visal Seqencer (GUI based programming
More informationBasic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators. JAVA Standard Edition
Basic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators JAVA Standard Edition Java - Basic Operators Java provides a rich set of operators to manipulate variables.
More informationSystems Programming and Computer Architecture ( )
(252-0061-00) Session 9 Floating Point Systems Group Department of Computer Science ETH Zürich 1 Floating Point Recap for the Assignment 2 Floating Point Representation Numerical Form Scientific Notation
More informationPushing squares around
Pshing sqares arond Adrian Dmitresc János Pach Ý Abstract We stdy dynamic self-reconfigration of modlar metamorphic systems. We garantee the feasibility of motion planning in a rectanglar model consisting
More informationThe single-cycle design from last time
lticycle path Last time we saw a single-cycle path and control nit for or simple IPS-based instrction set. A mlticycle processor fies some shortcomings in the single-cycle CPU. Faster instrctions are not
More informationAdaptive Influence Maximization in Microblog under the Competitive Independent Cascade Model
International Jornal of Knowledge Engineering, Vol. 1, No. 2, September 215 Adaptie Inflence Maximization in Microblog nder the Competitie Independent Cascade Model Zheng Ding, Kai Ni, and Zhiqiang He
More informationBasics of Digital Logic Design
ignals, Logic Operations and Gates E 675.2: Introdction to ompter rchitectre asics of igital Logic esign Rather than referring to voltage levels of signals, we shall consider signals that are logically
More informationDr Paolo Guagliardo. Fall 2018
The NULL vale Dr Paolo Gagliardo dbs-lectrer@ed.ac.k Fall 2018 NULL: all-prpose marker to represent incomplete information Main sorce of problems and inconsistencies... this topic cannot be described in
More informationOperators and Type Conversion. By Avani M. Sakhapara Assistant Professor, IT Dept, KJSCE
Operators and Type Conversion By Avani M. Sakhapara Assistant Professor, IT Dept, KJSCE Introduction An operator is a symbol which represents a particular operation that can be performed on some data.
More informationOn Plane Constrained Bounded-Degree Spanners
Algorithmica manscript No. (ill be inserted by the editor) 1 On Plane Constrained Bonded-Degree Spanners 2 3 Prosenjit Bose Rolf Fagerberg André an Renssen Sander Verdonschot 4 5 Receied: date / Accepted:
More informationCSE 351 Midterm - Winter 2015 Solutions
CSE 351 Midterm - Winter 2015 Solutions February 09, 2015 Please read through the entire examination first! We designed this exam so that it can be completed in 50 minutes and, hopefully, this estimate
More informationProf. Kozyrakis. 1. (10 points) Consider the following fragment of Java code:
EE8 Winter 25 Homework #2 Soltions De Thrsday, Feb 2, 5 P. ( points) Consider the following fragment of Java code: for (i=; i
More informationEE 109 Unit 6 Binary Arithmetic
EE 109 Unit 6 Binary Arithmetic 1 2 Semester Transition Point At this point we are going to start to transition in our class to look more at the hardware organization and the low-level software that is
More informationLe L c e t c ur u e e 2 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Variables Operators
Course Name: Advanced Java Lecture 2 Topics to be covered Variables Operators Variables -Introduction A variables can be considered as a name given to the location in memory where values are stored. One
More informationGroups of two-state devices are used to represent data in a computer. In general, we say the states are either: high/low, on/off, 1/0,...
Chapter 9 Computer Arithmetic Reading: Section 9.1 on pp. 290-296 Computer Representation of Data Groups of two-state devices are used to represent data in a computer. In general, we say the states are
More informationUSING MAPLE FOR VISUALIZATION OF TOPOLOGICAL SUBGROUPOIDS OF X Z X
USING MAPLE FOR VISUALIZATION OF TOPOLOGICAL SUBGROUPOIDS OF X Z X Mădălina Roxana BUNECI, Uniersity Constantin Brâncşi of Târg-Ji Abstract. The prpose of this paper is to present arios ways to isalize
More informationCS 557 Lecture IX. Drexel University Dept. of Computer Science
CS 7 Lectre IX Dreel Uniersity Dept. of Compter Science Fall 00 Shortest Paths Finding the Shortest Paths in a graph arises in many different application: Transportation Problems: Finding the cheapest
More informationCS113: 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;
More information