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

Size: px
Start display at page:

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

Transcription

1 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 corse syllabs careflly for all corse policies, personnel info, and corse logis?cs. Moodle. Web page: Use yor niversity x5 accont to access Class forms, assignment sbmission, exam info h7ps://ay15.moodle.mn.ed/corse/view.php?id13 Data Representa?on: Bits, Bytes, and CSci 1 - Machine Architectre and Organiza?on Professor Pen- Chng Yew With sides from Randy Bryant and Dave O Hallaron 1 Bits, Bytes, and Representa?on: nsigned and signed Expanding, trnca?ng Addi?on, nega?on, ml?plica?on, divide with shio Smmary Binary Representa?ons Each bit is or 1 Why bits? Electronic Implementa?on Easy to store with bistable elements, e.g. switches, transistors, Reliably transmi7ed on noisy wires By encoding/interpre?ng sets of bits in varios ways Compters determine what to do (instrcuons), and represent and maniplate nmbers, sets, strings, etc 1.1V.9V 1 3.V.V Base- nmber representa?on Decimal to Binary Represent 15 1 as 111 Represent 1. 1 as 1.11[11] (binary repetend) Represent 1.51 X 1 as 1.11 X 7 Binary to Decimal Represent 111 as 1 Represent as Represent X 3 as 1.35 X 1 1 Encoding Byte Vales Byte bits Binary to Decimal: 1 to 551 Hexadecimal: 1 to 1 Base 1 nmber representauon Use characters to 9 and A to F Write FA1D37BE1 in C as xfa1d37be xfa1d37be xfa1d37be F A 1 D 3 7 B E Hex Decimal Binary A 1 11 B C 1 11 D E F

2 Example Data Representa?ons Today: Bits, Bytes, and C Data Type Typical 3- bit Typical - bit x- char short int long float doble long doble 1/1 pointer RepresentaUon: nsigned and signed Conversion, casung Expanding, trncaung AddiUon, negauon, mluplicauon, divide with shic Smmary 7 Boolean Algebra Developed by George Boole in 19th Centry Algebraic representauon of logic Encode Tre as 1 and False as And Or n A&B 1 when both A1 and B1 n A B 1 when either A1 or B1 B B A A Not Exclsive- Or (Xor) n ~A 1 when A n A^B 1 when either A1 or B1, bt not both B Applica?on of Boolean Algebra Applied to Digital Systems by Clade Shannon 1937 MIT Master s Thesis Reason abot networks of relay switches Encode closed switch as 1, open switch as A ~A A&~B ~B B ~A&B Connection when A&~B ~A&B A^B A A 9 1 General Boolean Algebras Represen?ng & Manipla?ng Sets Operate on Bit Vectors OperaUons applied bitwise 1111 & ^ ~ All of the Proper?es of Boolean Algebra Apply 11 Representa?on Width w bit vector represents sbsets of {,, w 1} a j 1 if j A 1111 A {, 3, 5, } A {,,, } 7531 Opera?ons & IntersecUon 11 {, } Union {,, 3,, 5, } ^ Symmetric difference 1111 {, 3,, 5 } ~ Complement 1111 { 1, 3, 5, 7 } 1

3 Bit- Level Opera?ons in C Opera?ons &,, ~, ^ Available in C Apply to any integral data type long, int, short, char, nsigned View argments as bit vectors Argments applied bit- wise Examples (char data type) (1 byte) ~x1 xbe ~ ~x x ~ x9 & x55 x & x9 x55 x7d Contrast: Logic Opera?ons in C Contrast to Logical Operators &&,,! View as False Anything nonzero as Tre Always retrn or 1 Examples (char data type)!x1 x (different from ~ operauon)!x x1!!x1 x1 x9 && x55 x1 x9 x55 x Contrast: Logic Opera?ons in C Contrast to Logical Operators &&,,! View as False Anything nonzero as Tre Always retrn or 1 Early terminauon Examples (char data type)!x1 x!x x1!!x1 x1 Watch ot for && vs. & (and vs. ) one of the more common oopsies in C programming x9 && x55 x1 x9 x55 x1 ShiO Opera?ons LeO ShiO: x << y ShiO bit- vector x leo y posi?ons Throw away extra bits on leo Fill with s on right Right ShiO: x >> y ShiO bit- vector x right y posi?ons Throw away extra bits on right Logical shio Fill with s on leo Arithme?c shio Replicate most significant bit on leo Undefined Behavior ShiO amont < or word size Argment x 111 << 3 1 Log. >> 11 Arith. >> 11 Argment x 111 << 3 1 Log. >> 11 Arith. >> Annoncement 1/5/1 Programming Assignment #1 (Data Lab) will be issed today, de in weeks on //1 11:55pm Monday Download Data Lab from class Moodle page This lab asks yo to maniplate bit strings sing restricted instrcuon types and conts Each problem in the assignment has different degrees of difficlty, start with easier ones first. Feel free to se class Form to ask qesuons and get informauon from TA or other stdents TA will discss Data Lab in Thr recitauon sessions. Today: Bits, Bytes, and Representa?on: nsigned and signed Expanding, trnca?ng Addi?on, nega?on, ml?plica?on, divide with shio Smmary Smmary

4 Encoding Unsigned and Signed Unsigned (BU) w 1 BU(X) x i i i short int x 1513; short int y -1513; Two s Complement (BT) w BT(X) x w 1 w 1 + x i i i Sign Bit For s complement, most significant bit indicates sign for nonnega?ve 1 for nega?ve In C, data type short is bytes long Decimal Hex Binary x B D y C Sign Bit 19 Encoding Example (Binary to Unsigned BU ) x 1513: y -1513: Weight Sm w 1 BU(X) x i i i w BT(X) x w 1 w 1 + x i i i Binary Weight Table x 1 K 1 +1 x 1 K x 1 K 1 +1 x 1 1K x 1 3K 1 +1 x 1 K x 1 1K 1 +1 x 1 5K x 1 51K x 1 1M 1 Conver?ng Unsigned to Binary (UB) Dividing the nmber repeatedly by n?l the nmber becomes 9? - 9? BU(X) w 1 x i i i Same algorithm to ANY nmber system Divide by Nmber Remainder x x + x 3 + x + x x 9 Nmeric Ranges Unsigned Vales UMin UMax w Ranges for w 1, i.e. bytes (short) Decimal Hex Binary UMax TMax 377 7F TMin Two s Complement Vales Tmin w 1 1 Tmax w Other Vales Mins 1 w w BT(X) x w 1 w 1 + x i i i w 1 BU(X) x i i i Vales for Different Word Sizes w"! "" 1"(short)" 3"(int) "(long)" UMax" 55! 5,535!,9,97,95! 1,,7,73,79,551,15! TMax" 17! 3,77!,17,3,7! 9,3,37,3,5,775,7! TMin" -1! -3,7! -,17,3,! -9,3,37,3,5,775,!!! Observa?ons TMin TMax + 1 Asymmetric range UMax * TMax + 1 C Programming #inclde <limits.h> Declares constants, e.g., ULONG_MAX LONG_MAX LONG_MIN Vales plalorm specific Need to know - > to avoid overflow 3

5 Unsigned & Signed Integer Vales X BU(X) BT(X) Eqivalence Same encodings for nonnegauve/ negauve integer vales Uniqeness Every bit pa7ern represents niqe integer vale Each representable integer has niqe bit encoding Can Invert Mappings UB(x) BU - 1 (x) Bit pa7ern for nsigned integer TB(x) BT - 1 (x) Bit pa7ern for two s comp integer Today: Bits, Bytes, and Representa?on: nsigned and signed Expanding, trnca?ng Addi?on, nega?on, ml?plica?on, divide with shio Smmary 5 Mapping Between Signed & Unsigned Signed (Two s Complement) x Unsigned x TU TB X BU Maintain Same Bit Paoern UT UB BT X Maintain Same Bit Paoern Unsigned x Signed (Two s Complement) x Mappings between nsigned and two s complement nmbers: keep bit representa?ons and reinterpret 7 Mapping Signed Unsigned Bits Signed TU UT Unsigned Mapping Signed Unsigned Bits Signed /- 1 Unsigned Rela?on between Signed & Unsigned Two s Complement w 1 x x Large nega?ve weight becomes Large posi?ve weight x TU TB X BU Maintain Same Bit Paoern x Unsigned x x x x + w x < 3 5

6 Conversion Visalized Signed Unsigned Ordering Inversion NegaUve Big PosiUve Warning: Can case a lot of confsion and bgs in C!!! TMax UMax UMax 1 TMax + 1 TMax Unsigned Range Annoncement 1/7/1 This Thrsday s recita?on sessions will cover both Data Lab assignment, and more C programming langage featres. s Complement Range 1 TMin 31 3 Review: Signed vs. Unsigned in C Constants By defalt are considered to be signed integers Unsigned if have U as sffix U, 99759U Cas?ng (i.e. conversion) Explicit cas?ng between signed & nsigned same as UT and TU int tx, ty; nsigned x, y; tx (int) x; y (nsigned) ty; Implicit cas?ng also occrs via assignments and procedre calls tx x; y ty; 33 Review: Cas?ng Srprises Expression Evala?on If there is a mix of nsigned and signed in single expression, signed vales implicitly cast to nsigned Inclding comparison operauons <, >,, <, > Examples for w 3: TMIN -,17,3,, TMAX,17,3,7 Constant 1 Constant Rela?on Evala?on U U nsigned < signed U U > nsigned > signed 1737U < nsigned > signed (nsigned) > nsigned U < nsigned (int) 173U > signed 3 Smmary Cas?ng Signed Unsigned: Basic Rles Bit paoern is maintained (i.e. kept the same) Bt reinterpreted Can have nexpected effects: adding or sbtrac?ng w Expression containing nsigned and signed int int is cast to nsigned!! Today: Bits, Bytes, and Representa?on: nsigned and signed Expanding, trnca?ng Addi?on, nega?on, ml?plica?on, divide with shio Smmary 37 3

7 Sign Extension Task: Given w- bit signed integer x Convert it to w+k- bit integer with same vale Rle: Make k copies of sign bit: X ʹ x w 1,, x w 1, x w 1, x w,, x k copies of MSB X w X ʹ k w 39 Sign Extension Example short int x 1513; int ix (int) x; short int y -1513; int iy (int) y; Conver?ng from smaller to larger integer data type C atoma?cally performs sign extension Decimal Hex Binary x B D ix B D y C iy C Smmary: Expanding, Trnca?ng: Basic Rles Expanding (e.g., short to int) Unsigned: zeros added Signed: sign extension Both yield expected reslt Trnca?ng (e.g., nsigned to nsigned short) Unsigned/signed: high- ordered bits are trncated Reslt reinterpreted Unsigned: mod operauon Signed: similar to mod For small nmbers yields expected behavior Today: Bits, Bytes, and Representa?on: nsigned and signed Expanding, trnca?ng Addi?on, nega?on, ml?plica?on, divide with shio Smmary 1 Nega?on: Complement & Increment Claim: Following Holds for s Complement ~x + 1 -x A Shortct to Calclate s Complement ObservaUon: ~x + x x ~x w BT(X) x w 1 w 1 + x i i i Complement & Increment Examples x 1513 x Ranges for short ( bytes) Decimal Hex Binary x B D ~x -151 C ~x C y C Decimal Hex Binary ~ ~+1 Decimal Hex Binary UMax TMax 377 7F TMin What abot Tmin? Tmin - Tmax

8 Unsigned Addi?on Operands: w bits Tre Sm: w+1 bits + v + v Discard Carry: w bits UAdd w (, v) Standard Addi?on Fnc?on Ignores carry otpt (overflow is not signaled as errors in C langage) Implements Modlar Arithme?c s UAdd w (, v) ( + v) mod w + v + v < w UAdd w (,v) + v w + v w Integer Addition Visalizing (Mathema?cal) Integer Addi?on Integer Addi?on - bit integers, v Compte tre sm Add (, v) Vales increase linearly with and v Forms planar srface Add (, v) v Visalizing Unsigned Addi?on Wraps Arond If tre sm w Overflow UAdd (, v) Two s Complement Addi?on Operands: w bits + v Tre Sm: w+1 bits + v Discard Carry: w bits TAdd w (, v) Tre Sm w+1 w Overflow Modlar Sm v TAdd and UAdd have Iden?cal Bit- Level Behavior Signed vs. nsigned addiuon in C: int s, t,, v; s (int) ((nsigned) + (nsigned) v); t + v Will give s t 7 TAdd Overflow Visalizing s Complement Addi?on Fnc?onality Tre sm reqires w+1 bits Drop off Most Significant Bit (MSB) Treat remaining bits as s comp. integer (w) 1 (w 1) (w 1) - 1 Tre Sm w PosOver NegOver TAdd Reslt Vales - bit two s comp. Range from - to +7 Wraps Arond If sm w 1 Becomes negauve If sm < w 1 Becomes posiuve NegOver TAdd (, v) v PosOver 9 5

9 Characterizing TAdd Unsigned Ml?plica?on in C Fnc?onality Tre sm reqires w+1 bits Drop off MSB Treat remaining bits as s comp. integer TAdd(, v) > v < NegaUve Overflow < > PosiUve Overflow + v + w 1 + v < TMin w (NegOver) TAdd w (,v) + v TMin w + v TMax w + v w 1 TMax w < + v (PosOver) Operands: w bits Tre Prodct: *w bits Discard w bits: w bits v Standard Ml?plica?on Fnc?on Ignores high order w bits Implements Modlar Arithme?c UMlt w (, v) v mod w * v UMlt w (, v) 51 5 Signed Ml?plica?on in C Operands: w bits Tre Prodct: *w bits Discard w bits: w bits v Standard Ml?plica?on Fnc?on Ignores high order w bits Some of which are different for signed vs. nsigned mluplicauon Lower bits are the same as nsigned mluplicauon * v TMlt w (, v) Ml?plica?on Comp?ng Exact Prodct of w- bit nmbers x, y Either signed or nsigned Ranges Unsigned: Up to w bits Reslt range: x * y ( w 1) w w Two s complement min (negauve) : Up to w 1 bits Reslt range: x * y ( w 1 )*( w 1 1) w + w 1 Two s complement max (posiuve): Up to w bits, bt only for (TMin w ) Reslt range: x * y ( w 1 ) w Maintaining Exact Reslts Wold need to keep expanding word size with each prodct compted Done in socware by arbitrary precision arithmeuc packages 53 5 Power- of- Ml?ply with ShiO Opera?on << k gives * k Both signed and nsigned Operands: w bits Tre Prodct: w+k bits k k 1 Discard k bits: w bits UMlt w (, k ) TMlt w (, k ) Examples << 3 * << 5 - << 3 ( * 3) ( * ) * Most machines shic and add faster than mluply Compiler generates this code atomaucally * k

10 Bits, Bytes, and Representa?on: nsigned and signed Expanding, trnca?ng Addi?on, nega?on, ml?plica?on, divide with shio Smmary Unsigned Power- of- Divide with ShiO Qo?ent of Unsigned by Power of >> k gives / k ( floor operauons) Uses logical right shic k Operands: / k 1 Division: Reslt: / k / k Division Compted Hex Binary x B D x >> D B x >> B x >> B Binary Point 57 5 Signed Power- of- Divide with ShiO Qo?ent of Signed by Power of x >> k gives x / k Uses arithme?c right shic Ok when >, bt ronds wrong direcuon when < (shold rond toward ) k x Binary Point Operands: / k 1 Division: x / k. Reslt: RondDown(x / k ) Division Compted Hex Binary y C y >> E y >> FC y >> C Correct Power- of- Divide Qo?ent of Nega?ve Nmber by Power of Want x / k (Rond toward, i.e. se ceiling opera?on) Compte as (x+ k -1)/ k In C: (x + (1<<k)-1) >> k Biase dividend toward Case 1: No ronding k Dividend: 1 + k Divisor: / k / k Biasing has no effect Binary Point Correct Power- of- Divide (Cont.) Case : Ronding Dividend: Divisor: k x 1 + k / k x / k 1 Incremented by Binary Point Today: Bits, Bytes, and RepresentaUon: nsigned and signed Conversion, casung Expanding, trncaung AddiUon, negauon, mluplicauon, divide with shic Smmary Biasing adds 1 to final reslt Incremented by 1 1 1

11 Arithme?c: Basic Rles Arithme?c: Basic Rles Addi?on: Normal addiuon followed by trncate, same operauon on bit level Unsigned: addiuon mod w MathemaUcal addiuon & Possible sbtracuon of w Signed: modified addiuon mod w (reslt in proper range) MathemaUcal addiuon & Possible addiuon or sbtracuon of w Ml?plica?on: (prodct has w bits) Normal mluplicauon followed by trncate, same operauon on bit level Unsigned: mluplicauon mod w (reslt in proper range) Signed: modified mluplicauon mod w (reslt in proper range) LeO shio (Ml?plica?on) Unsigned/signed: mluplicauon by k Always logical leo shio Right shio (Division) Unsigned: logical right shic, div (division + rond toward zero) by k Signed: arithmeuc right shic Posi?ve nmbers: div (division + rond toward zero) by k Nega?ve nmbers: div (division + rond away from zero) by k Use biasing to fix 3 Integer C Pzzle Tmin and Tmax make a good conter example in many cases 1. x < ((x*) < ) False: TMin. x > Tre: UMin 3. x & 7 7 (x<<3) < Tre: x 1 1. x > -1 False: 5. x > y -x < -y False: -1, TMin. x * x > False: 3 7. x > && y > x + y > False: TMax, TMax. x > -x < Tre: TMax < 9. x < -x > False: TMin Today: Bits, Bytes, and Representa?on: nsigned and signed Expanding, trnca?ng Addi?on, nega?on, ml?plica?on, divide with shio Smmary Data representa?on in memory, pointers, character strings int x foo(); int y bar(); nsigned x x; Ini?aliza?on nsigned y y; 9 Byte- Oriented Memory Organiza?on F System provides a private address space to each process Think of a process as a program being exected A program can clobber its own data, bt not that of others Machine Words Any given machine has a Word Size Nominal size of integer- valed data Inclding addresses Many crrent machines se 3 bits ( bytes) words Limits addresses to GB Becoming too small for memory- intensive applicauons 1 1 mega giga tera peta exa zeoa- 1 1 yooa- Programs refer to data by address Conceptally, envision it as a very large array of bytes In reality, it s not, bt can think of it that way An address is like an index into that array and, a pointer variable stores an address Most high- end systems se bits ( bytes) words PotenUal address space 1 X 1 1 bytes (exabytes) Machines spport mluple data formats (data types) FracUons or mluples of word size Always integral nmber of bytes

12 Word- Oriented Memory Organiza?on Addresses specify byte loca?ons Address of first byte in a word Addresses of sccessive words differ by (3- bit) or (- bit) Need to dis?ngish the no?on of address vs. data stored in that address 3-bit Words Addr?? Addr?? Addr?? Addr 1?? -bit Words Addr?? Addr?? Bytes Addr Byte Ordering How shold bytes within a ml?- byte word be ordered in memory? Conven?ons Big Endian: Sn, PPC Mac, Internet Most significant byte first Least significant byte has highest address, i.e Liole Endian: x, ARM processors rnning Android, ios and Windows Least significant byte first Least significant byte has lowest address, i.e. 73 Annoncement /1/1 Homework Assignment #1 has been issed today Download from Moodle class web page De date before class Wednesday /1/1 (check class schedle) Data Lab de next Monday //1 Shold start asap, if not yet Check Data Lab Form for common Q&As, or post yor problem there. Review: Byte Ordering Example Big Endian Most significant byte first i.e. Least significant byte has highest address Liole Endian Least significant byte first i.e. Least significant byte has lowest address Example Variable x has - byte representauon x7531 Address given by &x is x1 Big Endian Little Endian x1 x11 x1 x x1 x11 x1 x Represen?ng int A 1513; IA3, x- D 3B IA3, x- 93 C Sn 3B D int B -1513; Sn C 93 Decimal: 1513 Binary: Hex: 3 B D long int C 1513; IA3 D 3B x- D 3B Two s complement representation Sn 3B D 7 Examining Data Representa?ons Code to Print Byte Representa?on of Data CasUng pointer to nsigned char * allows treatment as a byte array typedef nsigned char *pointer; void show_bytes(pointer start, size_t len){ size_t i; for (i ; i < len; i++) printf( %p\tx%.x\n",start+i, start[i]); printf("\n"); } Printf directives: %p: print pointer (i.e. address) %x: print Hexadecimal \t : tab \n: new line 79 1

13 show_bytes Exec?on Example Represen?ng Pointers int a 1513; printf("int a 1513;\n"); show_bytes((pointer) &a, sizeof(int)); int B -1513; int *P &B; Sn IA3 x- Reslt (Linx x-): int a 1513; x7fffb7f71dbc d x7fffb7f71dbd 3b x7fffb7f71dbe x7fffb7f71dbf EF FB C D F BF C 9 EC 7F Different compilers & machines assign different locauons to objects Even get different reslts each Ume rn program 1 Represen?ng Strings char S[] "13"; Strings in C Represented by array of characters Each character encoded in ASCII format Linx/x- Sn Standard 7- bit encoding of character set Character has code x3 3 3 Digit i has code x3+i 3 3 String shold be nll- terminated 3 3 Final character # invisible Compa?bility Byte ordering not an isse Move on to Floa?ng Point Nmbers ASCII: American Standard Code for InformaUon Interchange Unicode Consor?m 3 13

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Bits and Bytes. Why bits? Representing information as bits Binary/Hexadecimal Byte representations» numbers» characters and strings» Instructions

Bits and Bytes. Why bits? Representing information as bits Binary/Hexadecimal Byte representations» numbers» characters and strings» Instructions Bits and Bytes Topics Why bits? Representing information as bits Binary/Hexadecimal Byte representations» numbers» characters and strings» Instructions Bit-level manipulations Boolean algebra Expressing

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

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

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

Page 1. Where Have We Been? Chapter 2 Representing and Manipulating Information. Why Don t Computers Use Base 10?

Page 1. Where Have We Been? Chapter 2 Representing and Manipulating Information. Why Don t Computers Use Base 10? Where Have We Been? Class Introduction Great Realities of Computing Int s are not Integers, Float s are not Reals You must know assembly Memory Matters Performance! Asymptotic Complexity It s more than

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

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

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

Bits and Bytes January 13, 2005

Bits and Bytes January 13, 2005 15-213 The Class That Gives CMU Its Zip! Topics Bits and Bytes January 13, 25 Why bits? Representing information as bits Binary / Hexadecimal Byte representations» Numbers» Characters and strings» Instructions

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

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

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

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

Why Don t Computers Use Base 10? Lecture 2 Bits and Bytes. Binary Representations. Byte-Oriented Memory Organization. Base 10 Number Representation

Why Don t Computers Use Base 10? Lecture 2 Bits and Bytes. Binary Representations. Byte-Oriented Memory Organization. Base 10 Number Representation Lecture 2 Bits and Bytes Topics! Why bits?! Representing information as bits " Binary/Hexadecimal " Byte representations» numbers» characters and strings» Instructions! Bit-level manipulations " Boolean

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

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

Why Don t Computers Use Base 10? Lecture 2 Bits and Bytes. Binary Representations. Byte-Oriented Memory Organization. Base 10 Number Representation

Why Don t Computers Use Base 10? Lecture 2 Bits and Bytes. Binary Representations. Byte-Oriented Memory Organization. Base 10 Number Representation Lecture 2 Bits and Bytes Topics Why bits? Representing information as bits Binary/Hexadecimal Byte representations» numbers» characters and strings» Instructions Bit-level manipulations Boolean algebra

More information

Hardware: Logical View

Hardware: Logical View Hardware: Logical View CPU Memory Bus Disks Net USB Etc. 1 Hardware: Physical View USB I/O controller Storage connections CPU Memory 2 Hardware: 351 View (version 0) instructions? Memory CPU data CPU executes

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

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

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

CS 33. Data Representation, Part 1. CS33 Intro to Computer Systems VII 1 Copyright 2017 Thomas W. Doeppner. All rights reserved.

CS 33. Data Representation, Part 1. CS33 Intro to Computer Systems VII 1 Copyright 2017 Thomas W. Doeppner. All rights reserved. CS 33 Data Representation, Part 1 CS33 Intro to Computer Systems VII 1 Copyright 2017 Thomas W. Doeppner. All rights reserved. Number Representation Hindu-Arabic numerals developed by Hindus starting in

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

Data Representa+on in Memory

Data Representa+on in Memory Data Representa+on in Memory CSCI 2400 / ECE 3217: Computer Architecture Instructor: Prof. Jason FriAs Slides adapted from Bryant & O Hallaron s slides 1 Data Representa+on in Memory Basic memory organiza+on

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

Topics of this Slideset. CS429: Computer Organization and Architecture. It s Bits All the Way Down. Why Binary? Why Not Decimal?

Topics of this Slideset. CS429: Computer Organization and Architecture. It s Bits All the Way Down. Why Binary? Why Not Decimal? Topics of this Slideset CS429: Computer Organization and Architecture There are 10 kinds of people in the world: those who understand binary, and those who don t! Dr. Bill Young Department of Computer

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 11, 2017 at 08:58 CS429 Slideset 2: 1 Topics of this Slideset

More information

CSCI2467: Systems Programming Concepts

CSCI2467: Systems Programming Concepts CSCI2467: Systems Programming Concepts Slideset 2: Information as Data (CS:APP Chap. 2) Instructor: M. Toups Spring 2018 Course updates datalab out today! - due after Mardi gras... - do not wait until

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

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

Data Representa+on: Floa+ng Point Numbers

Data Representa+on: Floa+ng Point Numbers Data Representa+on: Floa+ng Point Numbers Csci 2021 - Machine Architecture and Organiza+on Professor Pen- Chung Yew With sides from Randy Bryant and Dave O Hallaron 1 Floa+ng Point Numbers Background:

More information

CSC 8400: Computer Systems. Represen3ng and Manipula3ng Informa3on. Background: Number Systems

CSC 8400: Computer Systems. Represen3ng and Manipula3ng Informa3on. Background: Number Systems CSC 8400: Computer Systems Represen3ng and Manipula3ng Informa3on Background: Number Systems 1 Analog vs. Digital System q Analog Signals - Value varies con1nuously q Digital Signals - Value limited to

More information

Byte Ordering. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Byte Ordering. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University Byte Ordering Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Memory Model Physical memory DRAM chips can read/write 4, 8, 16 bits DRAM modules

More information

Computer Architecture and System Software Lecture 02: Overview of Computer Systems & Start of Chapter 2

Computer Architecture and System Software Lecture 02: Overview of Computer Systems & Start of Chapter 2 Computer Architecture and System Software Lecture 02: Overview of Computer Systems & Start of Chapter 2 Instructor: Rob Bergen Applied Computer Science University of Winnipeg Announcements Website is up

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

CS 261 Fall Binary Information (convert to hex) Mike Lam, Professor

CS 261 Fall Binary Information (convert to hex) Mike Lam, Professor CS 261 Fall 2018 Mike Lam, Professor 3735928559 (convert to hex) Binary Information Binary information Topics Base conversions (bin/dec/hex) Data sizes Byte ordering Character and program encodings Bitwise

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

Data Representa5on. CSC 2400: Computer Systems. What kinds of data do we need to represent?

Data Representa5on. CSC 2400: Computer Systems. What kinds of data do we need to represent? CSC 2400: Computer Systems Data Representa5on What kinds of data do we need to represent? - Numbers signed, unsigned, integers, floating point, complex, rational, irrational, - Text characters, strings,

More information

Data Representa5on. CSC 2400: Computer Systems. What kinds of data do we need to represent?

Data Representa5on. CSC 2400: Computer Systems. What kinds of data do we need to represent? CSC 2400: Computer Systems Data Representa5on What kinds of data do we need to represent? - Numbers signed, unsigned, integers, floating point, complex, rational, irrational, - Text characters, strings,

More information

Byte Ordering. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Byte Ordering. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University Byte Ordering 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

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

Lecture 2: Number Representa2on

Lecture 2: Number Representa2on CSE 30: Computer Organization and Systems Programming Lecture 2: Number Representa2on Diba Mirza University of California, San Diego 1 Levels of Representation High Level Language Program (e.g., C) Compiler

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

Outline. Integer representa+on and opera+ons Bit opera+ons Floa+ng point numbers. Reading Assignment:

Outline. Integer representa+on and opera+ons Bit opera+ons Floa+ng point numbers. Reading Assignment: Outline Integer representa+on and opera+ons Bit opera+ons Floa+ng point numbers Reading Assignment: Chapter 2 Integer & Float Number Representa+on related content (Sec+on 2.2, 2.3, 2.4) 1 Why we need to

More information

Outline. Integer representa+on and opera+ons Bit opera+ons Floa+ng point numbers. Reading Assignment:

Outline. Integer representa+on and opera+ons Bit opera+ons Floa+ng point numbers. Reading Assignment: Outline Integer representa+on and opera+ons Bit opera+ons Floa+ng point numbers Reading Assignment: Chapter 2 Integer & Float Number Representa+on related content (Sec+on 2.2, 2.3, 2.4) 1 Why we need to

More information

Sign & Magnitude vs 2 s Complement ( Signed Integer Representa:ons)

Sign & Magnitude vs 2 s Complement ( Signed Integer Representa:ons) Sign & Magnitude vs 2 s Complement ( Signed Integer Representa:ons) Overview Unsigned Integers Representa:on (review) binary Signed Integers Representa:on sign & magnitude (S&M) 2 s complement (2 sc) arithme:c

More information

Memory, Data, & Addressing II CSE 351 Spring

Memory, Data, & Addressing II CSE 351 Spring Memory, Data, & Addressing II CSE 351 Spring 2018 http://xkcd.com/138/ Review Questions 1) If the word size of a machine is 64-bits, which of the following is usually true? (pick all that apply) a) 64

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

Roadmap. The Interface CSE351 Winter Frac3onal Binary Numbers. Today s Topics. Floa3ng- Point Numbers. What is ?

Roadmap. The Interface CSE351 Winter Frac3onal Binary Numbers. Today s Topics. Floa3ng- Point Numbers. What is ? The Hardware/So@ware Interface CSE351 Winter 013 Floa3ng- Point Numbers Roadmap C: car *c = malloc(sizeof(car)); c->miles = 100; c->gals = 17; float mpg = get_mpg(c); free(c); Assembly language: Machine

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

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

CS 153 Design of Operating Systems

CS 153 Design of Operating Systems CS 153 Design of Operating Systems Spring 18 Lectre 3: OS model and Architectral Spport Instrctor: Chengy Song Slide contribtions from Nael Ab-Ghazaleh, Harsha Madhyvasta and Zhiyn Qian Last time/today

More information

REMEMBER TO REGISTER FOR THE EXAM.

REMEMBER TO REGISTER FOR THE EXAM. REMEMBER TO REGISTER FOR THE EXAM http://tenta.angstrom.uu.se/tenta/ Floating point representation How are numbers actually stored? Some performance consequences and tricks Encoding Byte Values Byte =

More information

CSE351: Memory, Data, & Addressing I

CSE351: Memory, Data, & Addressing I CSE351: Memory, Data, & Addressing I CSE 351 Spring 2017 Instructor: Ruth Anderson Teaching Assistants: Dylan Johnson Kevin Bi Linxing Preston Jiang Cody Ohlsen Yufang Sun Joshua Curtis http://xkcd.com/138/

More information

Instructor: Randy H. Katz hap://inst.eecs.berkeley.edu/~cs61c/fa13. Fall Lecture #7. Warehouse Scale Computer

Instructor: Randy H. Katz hap://inst.eecs.berkeley.edu/~cs61c/fa13. Fall Lecture #7. Warehouse Scale Computer CS 61C: Great Ideas in Computer Architecture Everything is a Number Instructor: Randy H. Katz hap://inst.eecs.berkeley.edu/~cs61c/fa13 9/19/13 Fall 2013 - - Lecture #7 1 New- School Machine Structures

More information

Data III & Integers I

Data III & Integers I Data III & Integers I CSE 351 Spring 2017 Instructor: Ruth Anderson Teaching Assistants: Dylan Johnson Kevin Bi Linxing Preston Jiang Cody Ohlsen Yufang Sun Joshua Curtis Administrivia Everyone has VM

More information

Main Memory Organization

Main Memory Organization Main Memory Organization Bit Smallest piece of memory Stands for binary digit Has values 0 (off) or 1 (on) Byte Is 8 consecu>ve bits Word Usually 4 consecu>ve bytes Has an address 8 bits 0 1 1 0 0 1 1

More information

Course overview. Computer Organization and Assembly Languages Yung-Yu Chuang 2006/09/18. with slides by Kip Irvine

Course overview. Computer Organization and Assembly Languages Yung-Yu Chuang 2006/09/18. with slides by Kip Irvine Course overview Computer Organization and Assembly Languages Yung-Yu Chuang 2006/09/18 with slides by Kip Irvine Logistics Meeting time: 9:10am-12:10pm, Monday Classroom: CSIE Room 102 Instructor: Yung-Yu

More information

Memory, Data, & Addressing II

Memory, Data, & Addressing II Memory, Data, & Addressing II CSE 351 Autumn 2018 Instructor: Justin Hsia Teaching Assistants: Akshat Aggarwal An Wang Andrew Hu Brian Dai Britt Henderson James Shin Kevin Bi Kory Watson Riley Germundson

More information

Floa.ng Point : Introduc;on to Computer Systems 4 th Lecture, Sep. 10, Instructors: Randal E. Bryant and David R.

Floa.ng Point : Introduc;on to Computer Systems 4 th Lecture, Sep. 10, Instructors: Randal E. Bryant and David R. Floa.ng Point 15-213: Introduc;on to Computer Systems 4 th Lecture, Sep. 10, 2015 Instructors: Randal E. Bryant and David R. O Hallaron Today: Floa.ng Point Background: Frac;onal binary numbers IEEE floa;ng

More information

CS107, Lecture 3 Bits and Bytes; Bitwise Operators

CS107, Lecture 3 Bits and Bytes; Bitwise Operators CS107, Lecture 3 Bits and Bytes; Bitwise Operators reading: Bryant & O Hallaron, Ch. 2.1 This document is copyright (C) Stanford Computer Science and Nick Troccoli, licensed under Creative Commons Attribution

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

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

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

More information

CS 153 Design of Operating Systems Spring 18

CS 153 Design of Operating Systems Spring 18 CS 153 Design of Operating Systems Spring 18 Lectre 2: Historical Perspective Instrctor: Chengy Song Slide contribtions from Nael Ab-Ghazaleh, Harsha Madhyvasta and Zhiyn Qian Last time What is an OS?

More information

CS107, Lecture 3 Bits and Bytes; Bitwise Operators

CS107, Lecture 3 Bits and Bytes; Bitwise Operators CS107, Lecture 3 Bits and Bytes; Bitwise Operators reading: Bryant & O Hallaron, Ch. 2.1 This document is copyright (C) Stanford Computer Science and Nick Troccoli, licensed under Creative Commons Attribution

More information

CS107, Lecture 2 Bits and Bytes; Integer Representations

CS107, Lecture 2 Bits and Bytes; Integer Representations CS107, Lecture 2 Bits and Bytes; Integer Representations reading: Bryant & O Hallaron, Ch. 2.2-2.3 This document is copyright (C) Stanford Computer Science and Nick Troccoli, licensed under Creative Commons

More information

CS 153 Design of Operating Systems Spring 18

CS 153 Design of Operating Systems Spring 18 CS 153 Design of Operating Systems Spring 18 Lectre 9: Synchronization (1) Instrctor: Chengy Song Slide contribtions from Nael Ab-Ghazaleh, Harsha Madhyvasta and Zhiyn Qian Cooperation between Threads

More information

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

More information

Data III & Integers I

Data III & Integers I Data III & Integers I CSE 351 Autumn 2018 Instructor: Justin Hsia Teaching Assistants: Akshat Aggarwal An Wang Andrew Hu Brian Dai Britt Henderson James Shin Kevin Bi Kory Watson Riley Germundson Sophie

More information

Topic Notes: Bits and Bytes and Numbers

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

More information

Data III & Integers I

Data III & Integers I Data III & Integers I 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

More information

Overview. ELEC2041 Microprocessors and Interfacing. Lecture 7: Number Systems - II. March 2006.

Overview. ELEC2041 Microprocessors and Interfacing. Lecture 7: Number Systems - II.   March 2006. ELEC2041 Microprocessors and Interfacing Lecture 7: Number Systems - II http://webct.edtec.unsw.edu.au/ March 2006 Saeid@unsw.edu.au Overview Signed Numbers: 2 Complement representation Addition, Subtraction

More information