Page # CISC360. Integers Sep 11, Encoding Integers Unsigned. Encoding Example (Cont.) Topics. Twoʼs Complement. Sign Bit

Size: px
Start display at page:

Download "Page # CISC360. Integers Sep 11, Encoding Integers Unsigned. Encoding Example (Cont.) Topics. Twoʼs Complement. Sign Bit"

Transcription

1 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 of overflow Using shifts to perform power-of-2 mltiply/divide Powerpoint Lectre Notes for Compter Systems: A Programmer's Perspective, R. Bryant and D. O'Hallaron, Prentice Hall, Fʼ2 Encoding Integers Unsigned Twoʼs Complement B2U(X) = w"1 # x i!2 i B2T(X) =!x w!1 "2 w!1 w!2 + # x i "2 i i= i= short int x = 15213; short int y = ; C short 2 bytes long Sign Bit Sign Bit Decimal Hex Binary x B D y C For 2ʼs complement, most significant bit indicates sign for nonnegative 1 for negative 2 CISC3 Fa8 Encoding Example (Cont.) x = 15213: y = : Weight Sm CISC3 Fa8

2 Nmeric Ranges Unsigned Vales UMin = UMax = 2 w Vales for W = 1 Twoʼs s Complement Vales TMin = 2 w 1 1 TMax = 2 w Other Vales Mins Decimal Hex Binary UMax 5535 FF FF TMax F FF TMin FF FF CISC3 Fa8 Vales for Different Word Sizes W UMax 255 5,535 4,294,97,295 18,44,744,73,79,551,15 TMax ,77 2,147,483,47 9,223,372,3,854,775,87 TMin ,78-2,147,483,48-9,223,372,3,854,775,88 Observations TMin = TMax + 1 Asymmetric range UMax = 2 * TMax + 1 C Programming #inclde <limits.h> K&R App. B11 Declares constants, e.g., ULONG_MAX LONG_MAX LONG_MIN Vales platform-specific 5 CISC3 Fa8 Unsigned & Signed Nmeric Vales X B2U(X) B2T(X) Eqivalence Same encodings for nonnegative vales Uniqeness Every bit pattern represents niqe integer vale Each representable integer has niqe bit encoding Can Invert Mappings U2B(x) = B2U -1 (x) Bit pattern for nsigned integer T2B(x) = B2T -1 (x) Bit pattern for twoʼs comp integer CISC3 Fa8

3 Casting Signed to Unsigned C Allows Conversions from Signed to Unsigned short int x = 15213; nsigned short int x = (nsigned short) x; short int y = ; nsigned short int y = (nsigned short) y; Reslting Vale No change in bit representation Nonnegative vales nchanged x = Negative vales change into (large) positive vales y = CISC3 Fa8 Relation between Signed & Unsigned Twoʼs Complement Unsigned T2U x T2B B2U x X Maintain Same Bit Pattern - w 1 x x w 1 2 w 1 = 2*2 w 1 = 2 w x = " x x! # $ x + 2 w x < 8 CISC3 Fa8 Relation Between Signed & Unsigned Weight Sm y = y + 2 * 3278 = y CISC3 Fa8

4 Signed vs. Unsigned in C Constants By defalt are considered to be signed integers Unsigned if have U as sffix U, U Casting Explicit casting between signed & nsigned same as U2T and T2U int tx, ty; nsigned x, y; tx = (int) x; y = (nsigned) ty; Implicit casting also occrs via assignments and procedre calls tx = x; y = ty; 1 CISC3 Fa8 Casting Srprises Expression Evalation If mix nsigned and signed in single expression, signed vales implicitly cast to nsigned Inclding comparison operations <, >, ==, <=, >= Examples for W = 32 Constant 1 Constant 2 Relation Evalation U == nsigned -1 < signed -1 U > nsigned > signed U < nsigned -1-2 > signed (nsigned) -1-2 > nsigned U < nsigned (int) U > CISC3 signedfa8 Explanation of Casting Srprises 2ʼs s Comp. Unsigned Ordering Inversion Negative Big Positive UMax UMax 1 TMax TMax + 1 TMax Unsigned Range 2ʼs Comp. Range 1 2 TMin 12 CISC3 Fa8

5 Sign Extension Task: Rle: Given w-bit signed integer x Convert it to w+k-bit integer with same vale Make k copies of sign bit: X = x w 1,, x w 1, x w 1, x w 2,, x k copies of MSB X w X 13 k w CISC3 Fa8 Sign Extension Example short int x = 15213; int ix = (int) x; short int y = ; int iy = (int) y; Decimal Hex Binary x B D ix B D y C iy FF FF C Converting from smaller to larger integer data type C atomatically performs sign extension 14 CISC3 Fa8 Jstification For Sign Extension Prove Correctness by Indction on k Indction Step: extending by single bit maintains vale X w - X - + w+1 Key observation: 2 w 1 = 2 w +2 w 1 Look at weight of pper bits: X 2 w 1 x w 1 X 2 w x w w 1 x w 1 = 2 w 1 x w 1 15 CISC3 Fa8

6 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 make mistakes for (i = cnt-2; 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 Working right p to limit of word size 1 CISC3 Fa8 Negating with Complement & Increment Claim: Following Holds for 2ʼs 2 s Complement ~x + 1 == -x Complement Observation: ~x + x == == -1 Increment ~x + x + (-x + 1) == -1 + (-x + 1) ~x + 1 == -x + x ~x Warning: Be catios treating intʼs as integers 17 OK here CISC3 Fa8 Comp. & Incr. Examples x = Decimal Hex Binary x B D ~x C ~x C y C Decimal Hex Binary ~ -1 FF FF ~+1 18 CISC3 Fa8

7 Unsigned Addition Operands: w bits + v Tre Sm: w+1 bits + v Discard Carry: w bits UAdd w (, v) Standard Addition Fnction Ignores carry otpt Implements Modlar Arithmetic s = UAdd w (, v) = + v mod 2 w UAdd w (,v) = # + v $ % + v! 2 w + v < 2 w + v " 2 w 19 CISC3 Fa8 Visalizing Integer Addition Integer Addition 4-bit integers, v Compte tre sm Add 4 (, v) Vales increase linearly with and v Forms planar srface Add 4 (, v) Integer Addition v 2 CISC3 Fa8 Visalizing Unsigned Addition Wraps Arond If tre sm 2 w At most once UAdd 4 (, v) Overflow Tre Sm 2 w+1 Overflow w Modlar Sm v 21 CISC3 Fa8

8 Mathematical Properties Modlar Addition Forms an Abelian Grop Closed nder addition UAdd w (, v) 2 w 1 Commtative UAdd w (, v) = UAdd w (v, ) Associative UAdd w (t, UAdd w (, v)) = UAdd w (UAdd w (t, ), v) is additive identity UAdd w (, ) = Every element has additive inverse Let UComp w ( ) = 2 w UAdd w (, UComp w ( )) = 22 CISC3 Fa8 Twoʼs Complement Addition Operands: w bits + v Tre Sm: w+1 bits + v Discard Carry: w bits TAdd w (, v) TAdd and UAdd have Identical Bit-Level Behavior Signed vs. nsigned addition in C: int s, t,, v; s = (int) ((nsigned) + (nsigned) v); t = + v Will give s == t 23 CISC3 Fa8 Characterizing TAdd Fnctionality Tre sm reqires w+1 bits Drop off MSB Treat remaining bits as 2ʼs comp. integer PosOver TAdd(, v) > v < < > NegOver w 1 2 w 1 2 w w Tre Sm 24 CISC3 Fa8 PosOver NegOver TAdd Reslt # + v + 2 w!1 % + v < TMin (NegOver) w TAdd w (,v) = $ + v TMin w " + v " TMax w % & + v! 2 w!1 TMax w < + v (PosOver)

9 Visalizing 2ʼs Comp. Addition Vales 4-bit twoʼs comp. Range from -8 to +7 Wraps Arond If sm 2 w 1 Becomes negative At most once If sm < 2 w 1 Becomes positive At most once NegOver TAdd 4 (, v) v 2 4 PosOver 25 CISC3 Fa8 Detecting 2ʼs Comp. Overflow Task Claim Given s = TAdd w (, v) Determine if s = Add w (, v) Example int s,, v; s = + v; Overflow iff either:, v <, s (NegOver), v, s < (PosOver) 2 w 1 2 w 1 ovf = (< == v<) && (<!= s<); PosOver NegOver 2 CISC3 Fa8 Mathematical Properties of TAdd Isomorphic Algebra to UAdd TAdd w (, v) = U2T(UAdd w (T2U( ), T2U(v))) Since both have identical bit patterns Twoʼs s Complement Under TAdd Forms a Grop Closed, Commtative, Associative, is additive identity Every element has additive inverse Let TComp w ( ) = U2T(UComp w (T2U( )) TAdd w (, TComp w ( )) = #! " TMin w TComp w () = $ % TMin w = TMin w 27 CISC3 Fa8

10 Mltiplication Compting Exact Prodct of w-bit nmbers x, y Either signed or nsigned Ranges Unsigned: x * y (2 w 1) 2 = 2 2w 2 w Up to 2w bits Twoʼs complement min: x * y ( 2 w 1 )*(2 w 1 1) = 2 2w w 1 Up to 2w 1 bits Twoʼs complement max: x * y ( 2 w 1 ) 2 = 2 2w 2 Up to 2w bits, bt only for (TMin w ) 2 Maintaining Exact Reslts Wold need to keep expanding word size with each prodct compted Done in software by arbitrary precision arithmetic packages 28 CISC3 Fa8 Unsigned Mltiplication in C Operands: w bits * v Tre Prodct: 2*w bits v Discard w bits: w bits UMlt w (, v) Standard Mltiplication Fnction Ignores high order w bits Implements Modlar Arithmetic UMlt w (, v) = v mod 2 w 29 CISC3 Fa8 Unsigned vs. 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 2 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) 3 CISC3 Fa8

11 Unsigned vs. 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 gives same bit-level reslt as nsigned p == (nsigned) p 31 CISC3 Fa8 Power-of-2 Mltiply with Shift Operation << k gives * 2 k Both signed and nsigned Operands: w bits Tre Prodct: w+k bits Examples 2 k Discard k bits: w bits UMlt w (, 2 k ) << 3 == * 8 << 5 - << 3 == * 24 k 1 Most machines shift and add mch faster than mltiply Compiler generates this code atomatically 32 CISC3 Fa8 * 2 k TMlt w (, 2 k ) Unsigned Power-of-2 Divide with Shift Qotient of Unsigned by Power of 2 >> k gives / 2 k Uses logical shift Operands: Division: / 2 k / 2 k k 1 Binary Point. Reslt: / 2 k Division Compted Hex Binary x B D x >> D B x >> B x >> B CISC3 Fa8

12 Signed Power-of-2 Divide with Shift Qotient of Signed by Power of 2 x >> k gives x / 2 k Uses arithmetic shift Ronds wrong direction when < k x Operands: / 2 k 1 Division: x / 2 k Binary Point. Reslt: RondDown(x / 2 k ) Division Compted Hex Binary y C y >> E y >> FC y >> FF C CISC3 Fa8 Correct Power-of-2 Divide Qotient of Negative Nmber by Power of 2 Want x / 2 k (Rond Toward ) Compte as (x+2 k -1)/ 2 k In C: (x + (1<<k)-1) >> k Biases dividend toward Case 1: No ronding Dividend: Divisor: / 2 k / 2 k k 1 +2 k Binary Point Biasing has no effect 35 CISC3 Fa8 Correct Power-of-2 Divide (Cont.) Case 2: Ronding Dividend: x k 1 +2 k Incremented by 1 Binary Point Divisor: / 2 k 1 x / 2 k Biasing adds 1 to final reslt Incremented by 1 3 CISC3 Fa8

13 Properties of Unsigned Arithmetic Unsigned Mltiplication with Addition Forms Commtative Ring Addition is commtative grop Closed nder mltiplication UMlt w (, v) 2 w 1 Mltiplication Commtative UMlt w (, v) = UMlt w (v, ) Mltiplication is Associative UMlt w (t, UMlt w (, v)) = UMlt w (UMlt w (t, ), v) 1 is mltiplicative identity UMlt w (, 1) = Mltiplication distribtes over addtion UMlt w (t, UAdd w (, v)) = UAdd w (UMlt w (t, ), UMlt w (t, v)) 37 CISC3 Fa8 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 2 w Comparison to Integer Arithmetic Both are rings Integers obey ordering properties, e.g., > + v > v >, v > v > These properties are not obeyed by twoʼs comp. arithmetic TMax + 1 == TMin * 342 == -13 (1-bit words) CISC3 Fa8 Work in Grop: C Pzzles Work in grop of two to solve these C pzzles Taken from old exams Assme machine with 32 bit word size, twoʼs complement integers For each of the following C expressions, either: Arge that is tre for all argment vales Give example where not tre x < ((x*2) < ) Initialization int x = foo(); int y = bar(); nsigned x = x; nsigned y = y; x >= x & 7 == 7 (x<<3) < x > -1 x > y -x < -y x * x >= x > && y > x + y > x >= -x <= 39 x <= CISC3 Fa8 -x >=

14 Schedle Lec3 - Integers (Sep 11) Lec4 - Floating point (Sep 1) o Reading assignment: chap o Qiz chap 2 Lec5 - Machine-Level Programming I - Introdction (Sep 18) Lec - Machine-Level Programming II - Introdction (Sep 25) o Lab 1 de 4 CISC3 Fa8

C Puzzles! Taken from old exams. Integers Sep 3, Encoding Integers Unsigned. Encoding Example (Cont.) The course that gives CMU its Zip!

C Puzzles! Taken from old exams. Integers Sep 3, Encoding Integers Unsigned. Encoding Example (Cont.) The course that gives CMU its Zip! 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,

More information

Page 1 CISC360. Encoding Integers Unsigned. Integers Sep 8, Numeric Ranges. Encoding Example (Cont.)

Page 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 information

Systems 1. Integers. Unsigned & Twoʼs complement. Addition, negation, multiplication

Systems 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 information

Integers Sep 3, 2002

Integers 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 information

Integers. Dr. Steve Goddard Giving credit where credit is due

Integers. 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 information

C Puzzles The course that gives CMU its Zip! Integer Arithmetic Operations Jan. 25, Unsigned Addition. Visualizing Integer Addition

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 information

Topics of this Slideset. CS429: Computer Organization and Architecture. Encoding Integers: Unsigned. C Puzzles. Integers

Topics 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 information

CS429: Computer Organization and Architecture

CS429: 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 information

Integers. Today. Next time. ! Numeric Encodings! Programming Implications! Basic operations. ! Floats

Integers. 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 information

Bits, Bytes, and Integers. Bits, Bytes, and Integers. The Decimal System and Bases. Everything is bits. Converting from Decimal to Binary

Bits, 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 information

Bits, Bytes, and Integer

Bits, 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 information

Integer Arithmetic. CS 347 Lecture 03. January 20, 1998

Integer 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 information

Systems Programming and Computer Architecture ( )

Systems 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 information

Bits, Bytes, and Integers August 26, 2009

Bits, 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 information

Computer Systems CEN591(502) Fall 2011

Computer 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 information

CS 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. 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 information

Today: 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. 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 information

Bits, Bytes, and Integers

Bits, 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 information

CS 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. 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 information

Bits, Bytes, and Integers. Data Representa+on: Base- 2 number representa+on. Binary Representa+ons. Encoding Byte Values. Example Data Representa+ons

Bits, 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 information

Representa7on of integers: unsigned and signed Conversion, cas7ng Expanding, trunca7ng Addi7on, nega7on, mul7plica7on, shiaing

Representa7on 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 information

Carnegie Mellon. Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition

Carnegie 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 information

CS140 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 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 information

Bits, Bytes, and Integers Part 2

Bits, 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 information

Representing and Manipulating Integers. Jo, Heeseung

Representing 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 information

Csci 2021 Class Web Pages. Data Representa?on: Bits, Bytes, and Integers. Binary Representa?ons. Bits, Bytes, and Integers

Csci 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 information

Bits, Bytes and Integers Part 1

Bits, 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 information

CS 270: Computer Organization. Integer Arithmetic Operations

CS 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 information

Lecture 5-6: Bits, Bytes, and Integers

Lecture 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 information

Jin-Soo Kim Systems Software & Architecture Lab. Seoul National University. Integers. Spring 2019

Jin-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 information

Arithmetic and Bitwise Operations on Binary Data

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

More information

Integer Encoding and Manipulation

Integer 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 information

But first, encode deck of cards. Integer Representation. Two possible representations. Two better representations WELLESLEY CS 240 9/8/15

But 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 information

Representing Integers. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Representing 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 information

Foundations of Computer Systems

Foundations 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 information

Representing and Manipulating Integers Part I

Representing 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 information

Computer Organization: A Programmer's Perspective

Computer 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 information

Representing Integers

Representing 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 information

BITS, BYTES, AND INTEGERS

BITS, 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 information

Arithmetic and Bitwise Operations on Binary Data

Arithmetic 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 information

Manipulating Integers

Manipulating 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 information

Bits, Bytes, and Integers

Bits, 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 information

System Programming CISC 360. Floating Point September 16, 2008

System 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 information

Bits, Bytes, and Integers

Bits, 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 information

Integers II. CSE 351 Autumn Instructor: Justin Hsia

Integers 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 information

ICS Instructor: Aleksandar Kuzmanovic TA: Ionut Trestian Recitation 2

ICS 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 information

Integers II. CSE 351 Autumn Instructor: Justin Hsia

Integers 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 information

Integers II. CSE 351 Autumn 2018

Integers 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 information

Bits, Bytes and Integers

Bits, 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 information

POWER-OF-2 BOUNDARIES

POWER-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 information

Integer Representation

Integer 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 information

Bits and Bytes: Data Presentation Mohamed Zahran (aka Z)

Bits 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 information

CS367 Test 1 Review Guide

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,

More information

Systems 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 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 information

Floating Point Puzzles. Lecture 3B Floating Point. IEEE Floating Point. Fractional Binary Numbers. Topics. IEEE Standard 754

Floating 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 information

Giving credit where credit is due

Giving 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 information

Giving credit where credit is due

Giving 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 information

Computer Organization: A Programmer's Perspective

Computer Organization: A Programmer's Perspective A Programmer's Perspective Representing Numbers Gal A. Kaminka galk@cs.biu.ac.il Fractional Binary Numbers 2 i 2 i 1 4 2 1 b i b i 1 b 2 b 1 b 0. b 1 b 2 b 3 b j 1/2 1/4 1/8 Representation Bits to right

More information

Chapter 2 Float Point Arithmetic. Real Numbers in Decimal Notation. Real Numbers in Decimal Notation

Chapter 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 information

CS: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 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 information

Floating Point Puzzles The course that gives CMU its Zip! Floating Point Jan 22, IEEE Floating Point. Fractional Binary Numbers.

Floating 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 information

COMP2611: Computer Organization. Data Representation

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

More information

Floating Point Puzzles. Lecture 3B Floating Point. IEEE Floating Point. Fractional Binary Numbers. Topics. IEEE Standard 754

Floating 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 information

Programming in C++ 5. Integral data types

Programming 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 information

Simple Data Types in C. Alan L. Cox

Simple 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 information

Floating Point January 24, 2008

Floating 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 information

Module 2: Computer Arithmetic

Module 2: Computer Arithmetic Module 2: Computer Arithmetic 1 B O O K : C O M P U T E R O R G A N I Z A T I O N A N D D E S I G N, 3 E D, D A V I D L. P A T T E R S O N A N D J O H N L. H A N N E S S Y, M O R G A N K A U F M A N N

More information

Number Systems Standard positional representation of numbers: An unsigned number with whole and fraction portions is represented as:

Number Systems Standard positional representation of numbers: An unsigned number with whole and fraction portions is represented as: N Number Systems Standard positional representation of numbers: An unsigned number with whole and fraction portions is represented as: a n a a a The value of this number is given by: = a n Ka a a a a a

More information

CS:APP Web Aside DATA:TMIN: Writing TMin in C

CS:APP Web Aside DATA:TMIN: Writing TMin in C CS:APP Web Aside DATA:TMIN: Writing TMin in C Randal E. Bryant David R. O Hallaron December 29, 2014 Notice The material in this document is supplementary material to the book Computer Systems, A Programmer

More information

Semester Transition Point. EE 109 Unit 11 Binary Arithmetic. Binary Arithmetic ARITHMETIC

Semester 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 information

CS429: Computer Organization and Architecture

CS429: 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 information

Arithmetic Operators. Portability: Printing Numbers

Arithmetic 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 information

CS 261 Fall Mike Lam, Professor Integer Encodings

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

More information

The course that gives CMU its Zip! Floating Point Arithmetic Feb 17, 2000

The 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 information

Integer Representation Floating point Representation Other data types

Integer 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 information

Arithmetic Processing

Arithmetic Processing CS/EE 5830/6830 VLSI ARCHITECTURE Chapter 1 Basic Number Representations and Arithmetic Algorithms Arithmetic Processing AP = (operands, operation, results, conditions, singularities) Operands are: Set

More information

Foundations of Computer Systems

Foundations of Computer Systems 18-600 Foundations of Computer Systems Lecture 4: Floating Point Required Reading Assignment: Chapter 2 of CS:APP (3 rd edition) by Randy Bryant & Dave O Hallaron Assignments for This Week: Lab 1 18-600

More information

Chapter 4. Operations on Data

Chapter 4. Operations on Data Chapter 4 Operations on Data 1 OBJECTIVES After reading this chapter, the reader should be able to: List the three categories of operations performed on data. Perform unary and binary logic operations

More information

CHW 261: Logic Design

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

More information

World Inside a Computer is Binary

World Inside a Computer is Binary C Programming 1 Representation of int data World Inside a Computer is Binary C Programming 2 Decimal Number System Basic symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Radix-10 positional number system. The radix

More information

Review. How to represent real numbers

Review. 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 information

Systems Programming and Computer Architecture ( )

Systems 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 information

Floating-Point Data Representation and Manipulation 198:231 Introduction to Computer Organization Lecture 3

Floating-Point Data Representation and Manipulation 198:231 Introduction to Computer Organization Lecture 3 Floating-Point Data Representation and Manipulation 198:231 Introduction to Computer Organization Instructor: Nicole Hynes nicole.hynes@rutgers.edu 1 Fixed Point Numbers Fixed point number: integer part

More information

CS61B Lecture #14: Integers. Last modified: Wed Sep 27 15:44: CS61B: Lecture #14 1

CS61B Lecture #14: Integers. Last modified: Wed Sep 27 15:44: CS61B: Lecture #14 1 CS61B Lecture #14: Integers Last modified: Wed Sep 27 15:44:05 2017 CS61B: Lecture #14 1 Integer Types and Literals Type Bits Signed? Literals byte 8 Yes Cast from int: (byte) 3 short 16 Yes None. Cast

More information

Operations, Operands, and Instructions

Operations, Operands, and Instructions Operations, Operands, and Instructions Tom Kelliher, CS 220 Sept. 12, 2011 1 Administrivia Announcements Assignment Read 2.6 2.7. From Last Time Macro-architectural trends; IC fab. Outline 1. Introduction.

More information

Number Systems. Decimal numbers. Binary numbers. Chapter 1 <1> 8's column. 1000's column. 2's column. 4's column

Number Systems. Decimal numbers. Binary numbers. Chapter 1 <1> 8's column. 1000's column. 2's column. 4's column 1's column 10's column 100's column 1000's column 1's column 2's column 4's column 8's column Number Systems Decimal numbers 5374 10 = Binary numbers 1101 2 = Chapter 1 1's column 10's column 100's

More information

EE 109 Unit 6 Binary Arithmetic

EE 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 information

Floating Point. CSE 238/2038/2138: Systems Programming. Instructor: Fatma CORUT ERGİN. Slides adapted from Bryant & O Hallaron s slides

Floating Point. CSE 238/2038/2138: Systems Programming. Instructor: Fatma CORUT ERGİN. Slides adapted from Bryant & O Hallaron s slides Floating Point CSE 238/2038/2138: Systems Programming Instructor: Fatma CORUT ERGİN Slides adapted from Bryant & O Hallaron s slides Today: Floating Point Background: Fractional binary numbers IEEE floating

More information

Introduction to C. Why C? Difference between Python and C C compiler stages Basic syntax in C

Introduction to C. Why C? Difference between Python and C C compiler stages Basic syntax in C Final Review CS304 Introduction to C Why C? Difference between Python and C C compiler stages Basic syntax in C Pointers What is a pointer? declaration, &, dereference... Pointer & dynamic memory allocation

More information

Bitwise Data Manipulation. Bitwise operations More on integers

Bitwise 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 information

Digital Arithmetic. Digital Arithmetic: Operations and Circuits Dr. Farahmand

Digital Arithmetic. Digital Arithmetic: Operations and Circuits Dr. Farahmand Digital Arithmetic Digital Arithmetic: Operations and Circuits Dr. Farahmand Binary Arithmetic Digital circuits are frequently used for arithmetic operations Fundamental arithmetic operations on binary

More information

Floating point. Today! IEEE Floating Point Standard! Rounding! Floating Point Operations! Mathematical properties. Next time. !

Floating point. Today! IEEE Floating Point Standard! Rounding! Floating Point Operations! Mathematical properties. Next time. ! Floating point Today! IEEE Floating Point Standard! Rounding! Floating Point Operations! Mathematical properties Next time! The machine model Chris Riesbeck, Fall 2011 Checkpoint IEEE Floating point Floating

More information

CIS133J. Working with Numbers in Java

CIS133J. 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 information

CAPL Scripting Quickstart

CAPL 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 information

M1 Computers and Data

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

More information

SIGNED AND UNSIGNED SYSTEMS

SIGNED AND UNSIGNED SYSTEMS EE 357 Unit 1 Fixed Point Systems and Arithmetic Learning Objectives Understand the size and systems used by the underlying HW when a variable is declared in a SW program Understand and be able to find

More information

CS61B Lecture #14: Integers

CS61B Lecture #14: Integers Announcement: CS61B Lecture #14: Integers Project #0 due Tuesday night. Programming contest SATURDAY! You can still sign up at https://inst.eecs.berkeley.edu/~ctest/contest/register. Test #1 will be Tuesday,

More information

Module 2 - Part 2 DATA TYPES AND EXPRESSIONS 1/15/19 CSE 1321 MODULE 2 1

Module 2 - Part 2 DATA TYPES AND EXPRESSIONS 1/15/19 CSE 1321 MODULE 2 1 Module 2 - Part 2 DATA TYPES AND EXPRESSIONS 1/15/19 CSE 1321 MODULE 2 1 Topics 1. Expressions 2. Operator precedence 3. Shorthand operators 4. Data/Type Conversion 1/15/19 CSE 1321 MODULE 2 2 Expressions

More information

Lecture Topics. Announcements. Today: Integer Arithmetic (P&H ) Next: continued. Consulting hours. Introduction to Sim. Milestone #1 (due 1/26)

Lecture Topics. Announcements. Today: Integer Arithmetic (P&H ) Next: continued. Consulting hours. Introduction to Sim. Milestone #1 (due 1/26) Lecture Topics Today: Integer Arithmetic (P&H 3.1-3.4) Next: continued 1 Announcements Consulting hours Introduction to Sim Milestone #1 (due 1/26) 2 1 Overview: Integer Operations Internal representation

More information

Lecture 8: Addition, Multiplication & Division

Lecture 8: Addition, Multiplication & Division Lecture 8: Addition, Multiplication & Division Today s topics: Signed/Unsigned Addition Multiplication Division 1 Signed / Unsigned The hardware recognizes two formats: unsigned (corresponding to the C

More information