FALL 2017 CSCI 304 LAB2 (Due on October-10, 11:59:59pm)

Size: px
Start display at page:

Download "FALL 2017 CSCI 304 LAB2 (Due on October-10, 11:59:59pm)"

Transcription

1 FALL 2017 CSCI 304 LAB2 (Due on October-10, 11:59:59pm) OBJECTIVES: Manipulating Bits REMINDERS: Ø Every lab requires a README file. This file should include the following: o Student name(s) - to avoid the 10% deduction (as explained in the course syllabus) o Effort distribution for each contributor (assumed 100% if you are not working with a partner) o Total amount of time to complete the entire lab o Short description of any concerns, interesting problems or discoveries encountered, or comments in general about the contents of the lab o Directions on how to run the solution(s), as needed Ø You should aim to always hand an assignment in on time. If you are late (even by a minute or heaven forbid, less than a minute late), you will receive 50% of your earned points for the designated grade as long as the assignment is submitted by 11:59pm the following day, based on the due date listed on the syllabus and confirmed by the instructor. If you are more than 24 hours late, you will receive a zero for the assignment and your assignment will not be graded at all. Ø Any lab submitted that does not compile and run WILL RECEIVE AN AUTOMATIC GRADE OF ZERO. No exceptions will be made for this rule - to achieve even a single point on a lab your code must minimally compile and execute without crashing. Ø You are welcome to do more than what is required by the assignment as long as it is clear what you are doing and it does not interfere with the mandatory requirements. Ø You are responsible for making sure that your lab submits correctly. Ø Be sure that you are aware of the Coding Style file information posted on my Day by Day website. LAB DESCRIPTION Introduction The purpose of this assignment is to become more familiar with bit- level representations and manipulations. You ll do this by solving a series of programming puzzles. Many of these puzzles are artificial, but you ll find yourself thinking much more about bits in working your way through them. Project Instructions Any clarifications and revisions to the assignment will be posted on the course Web page. Start by copying datalab- handout.tar from my directory (on our lab machine/server) to a (protected) directory in which you plan to do your work. See the following commands.

2 mkdir cs304 cd cs304 chmod og- rwx. mkdir lab2 cd lab2 cp /home/f85/bren/software/lab2/datalab- handout.tar. # previous command will depend on location of the tar file will create a protected directory and move your source into this directory. Then give the command: tar xvf datalab- handout.tar This will cause 9 files to be unpacked into the directory: README- Instruts, Makefile, bits.h, btest.h, bits.c, btest.c, decl.c, dlc, and tests.c. The only file you will be modifying and turning in is bits.c. The file btest.c allows you to evaluate the functional correctness of your code. The file README- Instruts contains additional documentation about btest. Use the command make btest to generate the test code. Run the test code with the command./btest. Looking at the file bits.c you ll notice a C structure student into which you should insert the requested identifying information about you (your name and login id). If you are working in pairs, please specify only one s identifying information here, and put both of your information into README file. The btest test program will not run until you make this change. The bits.c file also contains a skeleton for each of the 17 programming puzzles. Your assignment is to complete each function skeleton, except the last one, using only straightline code (i.e., no loops or conditionals) and a limited number of C arithmetic and logical operators. Specifically, you are only allowed to use the following eight operators (see operators operator meaning! logical NOT ~ bitwise NOT & bitwise AND ^ bitwise XOR bitwise OR + addition << left shift >> right shift Allowable Operators A few of the functions further restrict this list, and there are several other general restrictions on the assignment. See the comments in bits.c for detailed rules and a discussion of the desired coding style. Solving these 17 puzzles will require fluent familiarity with the seven operators given in the table above. You would be well- advised to read carefully the corresponding

3 operations in operators A very useful tip for this project: The right shift operation (>>) Right shifting an unsigned quantity always fills vacated bits with zero (logical shift). Right shifting a signed quantity will fill with sign bits ("arithmetic shift") on our department machine. For example, the following will print out: x>>31=0xffffffff, y>>31=0x1, 0x >>31=0x1 a>>31=0x0, b>>31=0x0, 0x >>31=0x0 #include <stdio.h> int main() { int x = 0x , a=0x ; unsigned int y = 0x , b=0x ; printf("x>>31=0x%x, y>>31=0x%x, 0x >>31=0x%x\n", x>>31,y>>31, 0x >>31); printf("a>>31=0x%x, b>>31=0x%x, 0x >>31=0x%x\n", a>>31,b>>31, 0x >>31); return 0; } PLEASE READ THE HINTS IN THE END OF THIS PAGE FIRST. Evaluation Your code will be compiled with gcc and run and tested on one of the departmental Linux workstations. Your score will be computed out of a maximum of 84 points based on the following distribution: Correctness of code running on one of the class machines. Performance of code, based on number of operators used in each function. Style points, based on your instructor s subjective evaluation of the quality of your solutions and your comments. The 17 puzzles you must solve have been given a difficulty rating between 1 and 4, such that their weighted sum totals to 44. We will evaluate your functions using the test arguments in btest.c. You will get full credit for a puzzle if it passes all of the tests performed by btest.c, half credit if it fails one test, and no credit otherwise. Regarding performance, the main concern at this point in the course is that you can get the right answer. However, we want to instill in you a sense of keeping things as short and simple as you

4 can. Furthermore, some of the puzzles can be solved by brute force, but we want you to be more clever. Thus, for each function there is a maximum number of operators that you are allowed to use to implement that function. This limit is very generous and is designed only to catch egregiously inefficient solutions. You will receive two points for each function that satisfies the operator limit. Finally, 6 points are reserved for a subjective evaluation of the style of your solutions and your commenting. Your solutions should be as clean and straightforward as possible. Your comments should be informative, but they need not be extensive. Any function you attempt to solve that has no comments will be penalized. Part I: Bit manipulations Name Description Rating Max Ops bitand(x,y) Return (x&y) using only ~ and 1 8 copylsb() Return word with all bits set to 2 5 the least significant bit of x getbyte(x,n) Extract byte n from word x 2 6 isequal(x,y) Return 1 if x == y and 0 otherwise 2 5 bitmask(lowbit,highbit) Return a mask consisting of 1 s between 3 16 lowbit and highbit and zeros elsewhere reversebytes(x) Reverse the bytes of x 3 25 bang(x) Compute!x without using! 4 12 leastbitpos(x) Return a mask that marks the least 4 6 significant 1- bit of x Table 1: Bit- Level Manipulation Functions. Table 1 describes a set of functions that manipulate and test sets of bits. The Rating field gives the difficulty rating (the number of points) for the puzzle, and the Max ops field gives the maximum number of operators you are allowed to use to implement each function. Function bitand computes the AND function. That is, when applied to arguments x and y, it returns (x&y). You may only use the operators and ~. Function copylsb(x) returns the word with all bits set to the least significant bit of x. For example, the copylsb(5) call should return 0xffffffff, and the copylsb(6) call should return 0x Function getbyte(x,n) returns byte number n of x. Byte 0 is the least significant byte and byte 3 is the most significant byte. For example, the getbyte(0x ,0) call should return 0x78, and the getbyte(0x ,2) call should return 0x34. Function isequal(x,y) returns 1 if x == y and 0 otherwise.

5 Function bitmask(highbit,lowbit) returns a mask that is 1 between lowbit and highbit, inclusive, and is 0 elsewhere. You may assume that lowbit and highbit are both greater than or equal to 0 and less than or equal to 31. If lowbit > highbit, then the returned mask should be all zero. For example, the call bitmask(5,3) should return 0x (= ) (the rightmost bit is bit number 0). Function reversebytes(x) returns an int whose bytes are in the reverse order of the bytes of x. For example, the reversebytes(0x ) call should return 0x Function bang(x) returns!x without the use of the! operator. For example, bang(5) should return 0, and bang(0) should return 1. Function leastbitpos(x) returns a mask marking the least significant 1- bit of x. For example, the call leastbitpos(0x60) should return 0x (note that 0x60 = and that 0x20 = ). Part II: Two s Complement Arithmetic Name Description Rating Max Ops minusone(void) Returns a value of - 1 without using tmax(void) Return the maximum 32- bit two s 1 4 complement integer 0x7fff ffff fitsbits(x,n) Return 1 if x fits in an n- bit two s complement int, 2 15 otherwise, return 0 addok(x,y) Return 1 if x+y can be computed 3 20 without overflow, otherwise, return 0 isgreater(x,y) Returns 1 if x is greater than y; 3 24 otherwise, returns 0. IsNegative(x) Return 1 if x < 0, otherwise return multfiveeights(x) Returns the product of x and 5/8, rounded toward sm2tc(x) Interprets x as a sign- magnitude integer 4 15 and returns the value of x as a two s complement integer Table 2: Arithmetic Functions Table 2 describes a set of functions that make use of the two s complement representation of integers. Function minusone returns - 1 without using the minus operator. Function tmax returns the largest positive 32- bit two s complement int, namely 0x7fff ffff. Function fitsbits(x,n) returns 1 if its leftmost parameter x can be represented as an n- bit two s complement integer. You may assume that the number of bits n satisfies 1 n 32. For example, fitsbits(5,3) = 0, since 5 cannot be represented in 3 bits (the largest 3- bit positive number is 3), and fitsbits(- 4,3) = 1, since - 4 can be represented in 3 bits as 100 (it s the 3- bit TMin).

6 Function addok(x,y) returns 1 if the sum x+y can be computed without overflow; otherwise, it returns 0. For example, addok(0x , 0x ) = 0 addok(0x , 0x ) = 1 Function isgreater(x,y) returns 1 if x > y, otherwise, it returns 0. Function isnegative(x) returns 1 if x is negative; otherwise, it returns 0. Function multfiveeights(x) returns the product of x and 5/8, rounded toward 0, without causing overflow. For example, multfiveeights(77) = 48, and multfiveeights(- 22) = Function sm2tc(x) interprets its argument x as a sign- magnitude integer and returns the corresponding two s complement value. In the sign- magnitude number system, the leftmost bit is the sign bit 1 for negative and 0 for non- negative), and the remaining 31 bits give the magnitude (or absolute value) of the integer. The following table gives several sign- magnitude examples: Part III: Floating- Point Operations decimal hex sign magnitude 10 0x a x a - 0 0x x For this part of the assignment, you will implement some common single- precision floating- point operations. In this section, you are allowed to use standard control structures (conditionals, loops), and you may use both int and unsigned data types, including arbitrary unsigned and integer constants. You may not use any unions, structs, or arrays. Most significantly, you may not use any floating point data types, operations, or constants. Instead, any floating- point operand will be passed to the function as having type unsigned, and any returned floating- point value will be of type unsigned. Your code should perform the bit manipulations that implement the specified floating point operations. Table 3 describes a set of functions that operate on the bit- level representations of floating- point numbers. Refer to the comments in bits.c and the reference versions in tests.c for more information. Return bit- level equivalent of expression (float) x. Result is returned as unsigned int, but it is to be interpreted as the bit- level representation of a single- precision floating point values. For exmaple, float_i2f(1) should return 0x3f because 0x3f is the floating point representation of 1 = 1.0 * 2 0. Name Description Rating Max Ops float_i2f(x) Compute (float) x 4 30 Table 3: Floating- Point Functions.

7 The included program fshow helps you understand the structure of floating point numbers. To compile fshow, switch to the handout directory and type: unix> make You can use fshow to see what an arbitrary pattern represents as a floating- point number: unix>./fshow Floating point value e+36 Bit Representation 0x7c000000, sign = 0, exponent = f8, fraction = Normalized X 2^(121) You can also give fshow hexadecimal and floating point values, and it will decipher their bit structure. Submission Instructions Make sure you have included your identifying information in your files bits.c and README. To submit your bits.c and README files, type: make submit This target in the makefile first strips out the printf statements in your bits.c file, then invokes the submit program to submit both of your bits.c and README files. The submission can be repeated as many times as you wish. Only the most recently submitted version is retained. Backing Up Your Source Code Nothing is more frustrating that accidentally deleting a file that you have to hand in. To avoid this frustration, you should back up your source code regularly (such as, before you begin each editing session) with the command: make backup As you can see in the Makefile, the backup target creates a compressed tar file named backup.tar.gz that contains the Makefile and the files of the directory containing the Makefile having.c and.h suffixes. If you ever need to retrieve any of the backed up information, then type

8 gunzip - f backup.tar.gz; tar fxv backup.tar This will create a subdirectory of the current directory having the same name as the current directory where the files from the tar file are placed. For example, if your working directory is./lab1, then the tar fxv backup.tar command will extract the backed up files into a subdirectory./lab1/lab1. You can recover the files that you want from this subdirectory You should read the following hints: Advice You are expected to do your code development on one of the Linux workstations in M- S 121. Make sure that the version of bits.c that you turn in compiles and runs correctly on one of these machines. If you are accustomed to programming in C++ or Java, then programming in C will require a small adjustment from you. Unlike Java or C++, all variables that you use in a procedure must be declared at the beginning of the procedure. Your primary debugging tool will be the printf statement. For example, if you want to know the hexadecimal value of your int variable myvar, then insert the statement printf("%08x\n",myvar); where you want to check the variable s value. The %08x format specifies 8- column hexadecimal output with leading zeros, if necessary (see K&R, p. 153 for more information). A useful fact that you already know needs to be emphasized here, because you may be able to use it in several places: For a variable int x, the expression x>>31 is 0xffffffff if x < 0 and 0x if x 0. The dlc program, a modified version of an ANSI C compiler, will be used to check your programs for compliance with the coding style rules. Type dlc - help to display all of its options. This help output will show you, for example, that you can use dlc to measure the operator counts of your functions by executing the command:./dlc - e bits.c The dlc compiler balks at the #include <stdio.h> preprocessor statement, so do not include it, even though gcc will complain about printf being undeclared when you invoke make. Check the file README for documentation on running the btest program. You ll find it helpful to work through the functions one at a time, testing each one as you go. You can use the - f flag to instruct btest to test only a single function, e.g.,./btest - f addok.

9 Be sure to read carefully the comments at the top of the bits.c file. Note in particular that you cannot use in your code any constant larger than 0xff. Function bitmask(highbit,lowbit) returns a mask that is 1 between lowbit and highbit, inclusive, and is 0 elsewhere. You may assume that lowbit and highbit are both greater than or equal to 0 and less than or equal to 31. If lowbit > highbit, then the returned mask should be all zero. For example, the call bitmask(5,3) should return 0x (= ) (the rightmost bit is bit number 0). You can see bit 3,4,5 are all 1's. Hint: Some found it confusing. Give you another example: bitmask(6,3) should return 0x (= ). bit 0,1,2 are all 0, bit 3,4,5,6 are all 1's. Function bang(x) returns!x without the use of the! operator. For example, bang(5) should return 0, and bang(0) should return 1. Hint: compare 5 and - 5, also compare 0 and - 0. See any pattern you can use? Function leastbitpos(x) returns a mask marking the least significant 1- bit of x. For example, the call leastbitpos(0x60) should return 0x (note that 0x60 = and that 0x20 = ). Hint: compare x and - x. try x=0b See any pattern? Function fitsbits(x,n) returns 1 if its leftmost parameter x can be represented as an n- bit two s complement integer. You may assume that the number of bits n satisfies 1 n 32. For example, fitsbits(5,3) = 0, since 5 cannot be represented in 3 bits (the largest 3- bit positive number is 3), and fitsbits(- 4,3) = 1, since - 4 can be represented in 3 bits as 100 (it s the 3- bit TMin). Hint: You don't really need to compare the biggest and smallest n- bit numbers. Any number that can be represented in n bits has some pattern if you use 32 bits to represent it. Function addok(x,y) returns 1 if the sum x+y can be computed without overflow; otherwise, it returns 0. Hint: Only the sign bits matter. Function isgreater(x,y) returns 1 if x > y, otherwise, it returns 0. Hint: you have to consider the case for overflow. Function multfiveeights(x) returns the product of x and 5/8, rounded toward 0, without causing overflow. For example, multfiveeights(77) = 48, and multfiveeights(- 22) = - 13.

10 Hint: You should be able to get it correct for x>=0. For x<0, if 8 does not divide x, you need to adjust the quotient. Better way is to adjust x before you take division when x<0. For some problems in this lab, you may also want to make sure to check x and x's negation - x. - x=~x+1 This ~x+1 may give you a lot of useful information in several problems. For example, bang(x), leastbitpos(x), float_i2f(x) - - please use round to even. See B&O book pp The default rounding mode of IEEE floating- point is to use round- to- even. In the following, I will round off the last 7 bits. Those examples will give you a good understanding about round- to- even. A , This number is closer to than so we will use B , This number is closer to than so we will use C , This number is equal distance from and In round- to- even, we will round it to an even number, that is to: D , This number is equal distance from and

11 In round- to- even, we will round it to an even number, that is to: Examples: /* * isasciidigit - return 1 if 0x30 <= x <= 0x39 (ASCII codes for characters '0' to '9') * Example: isasciidigit(0x35) = 1. * isasciidigit(0x3a) = 0. * isasciidigit(0x05) = 0. * Legal ops:! ~ & ^ + << >> * Max ops: 15 * Rating: 3 */ int isasciidigit(int x) { int bias1 = ~0x2F; int bias2 = 0x3a; int lower = x + bias1; int upper = ~x + bias2; return!((lower upper) >> 31); } - - /* * sign - return 1 if positive, 0 if zero, and -1 if negative * Examples: sign(130) = 1 * sign(-23) = -1 * sign(0) = 0 * Legal ops:! ~ & ^ + << >> * Max ops: 10 * Rating: 2 */ int sign(int x) We can easily replicate sign bit by doing: x>>31 = 0x0 if x>=0; x>>31 = 0xffffffff=-1 if x<0 We are close now. We need to get 0x1 if x>0. Think hard, we can do the following: int sign(int x) { return (x>>31) (!!x); }

12 /* * absval - absolute value of x * Example: absval(-1) = 1. * You may assume -TMax <= x <= TMax * Legal ops:! ~ & ^ + << >> * Max ops: 10 * Rating: 4 */ int absval(int x) The program should run as follows: if (x>=0) return x; else return -x; we know - x=~x+1; We need to come up with x if x>=0, ~x+1 if x<0. How do we do this? Well, let's make some observation. The only difference between a negative int and a non- negative int is the sign bit. We can replicate the sign bit by doing the following: x>>31 This gives us 0XFFFFFFFF if x<0 and 0X if x>=0. Then (x>>31) ^ x gives us x if x>=0, and ~x if x<0. We are close now. We only need to come up with a 1 for x<0. The following generates a 1 for x<0 (x>>31) & 0x1 gives us 1 if x<0 and 0 if x>=0. Then the program is like this: int absval(int x) { int mask=x>>31; return (mask ^ x) + (mask & 1); }

BIL220, Spring 2012 Data Lab: Manipulating Bits Assigned: Feb. 23, Due: Wed., Mar. 8, 23:59PM

BIL220, Spring 2012 Data Lab: Manipulating Bits Assigned: Feb. 23, Due: Wed., Mar. 8, 23:59PM BIL220, Spring 2012 Data Lab: Manipulating Bits Assigned: Feb. 23, Due: Wed., Mar. 8, 23:59PM Ali Caglayan (alicaglayan@cs.hacettepe.edu.tr) and Oguzhan Guclu (oguzhanguclu@cs.hacettepe.edu.tr) are the

More information

MCS-284, Fall 2015 Data Lab: Manipulating Bits Assigned: Sept. 22, Due: Tues., Sept. 29, 11:59PM

MCS-284, Fall 2015 Data Lab: Manipulating Bits Assigned: Sept. 22, Due: Tues., Sept. 29, 11:59PM MCS-284, Fall 2015 Data Lab: Manipulating Bits Assigned: Sept. 22, Due: Tues., Sept. 29, 11:59PM 1 Introduction The purpose of this assignment is to become more familiar with bit-level representations

More information

CS 105 Lab 1: Manipulating Bits

CS 105 Lab 1: Manipulating Bits CS 105 Lab 1: Manipulating Bits See class calendar for lab and due dates Introduction The purpose of this assignment is to become more familiar with bit-level representations and manipulations. You ll

More information

CS-281, Spring 2011 Data Lab: Manipulating Bits Assigned: Jan. 17, Due: Mon., Jan. 31, 11:59PM

CS-281, Spring 2011 Data Lab: Manipulating Bits Assigned: Jan. 17, Due: Mon., Jan. 31, 11:59PM CS-281, Spring 2011 Data Lab: Manipulating Bits Assigned: Jan. 17, Due: Mon., Jan. 31, 11:59PM 1 Introduction The purpose of this assignment is to become more familiar with bit-level representations of

More information

EECS 213, Spring 2013 Data Lab: Manipulating Bits

EECS 213, Spring 2013 Data Lab: Manipulating Bits EECS 213, Spring 2013 Data Lab: Manipulating Bits 1 Introduction The purpose of this assignment is to become more familiar with bit-level representations of integers and floating point numbers. You ll

More information

CMSC 311 Spring 2010 Lab 1: Bit Slinging

CMSC 311 Spring 2010 Lab 1: Bit Slinging CMSC 311 Spring 2010 Lab 1: Bit Slinging Tim Meyer January 31, 2010 Post questions on this assignment to the CMSC 311 discussion board http://www.elms.umd.edu/. Introduction The purpose of this assignment

More information

Data Lab: Manipulating Bits

Data Lab: Manipulating Bits Data Lab: Manipulating Bits 1 Introduction The purpose of this assignment is to become more familiar with bit-level representations of integers and floating point numbers. You ll do this by solving a series

More information

CMSC 201, Fall 2014 Data Lab: Manipulating Bits Assigned: Sept. 03, Due: Wed., Sept. 17, 11:59PM

CMSC 201, Fall 2014 Data Lab: Manipulating Bits Assigned: Sept. 03, Due: Wed., Sept. 17, 11:59PM CMSC 201, Fall 2014 Data Lab: Manipulating Bits Assigned: Sept. 03, Due: Wed., Sept. 17, 11:59PM This lab was written by Randy Bryant and David O Hallaron, the authors of our textbook. 1 Introduction The

More information

Data Lab: Manipulating Bits

Data Lab: Manipulating Bits Data Lab: Manipulating Bits 1 Introduction The purpose of this assignment is to become more familiar with bit-level representations of integers and floating point numbers. You ll do this by solving a series

More information

CS 2505 Fall 2013 Data Lab: Manipulating Bits Assigned: November 20 Due: Friday December 13, 11:59PM Ends: Friday December 13, 11:59PM

CS 2505 Fall 2013 Data Lab: Manipulating Bits Assigned: November 20 Due: Friday December 13, 11:59PM Ends: Friday December 13, 11:59PM CS 2505 Fall 2013 Data Lab: Manipulating Bits Assigned: November 20 Due: Friday December 13, 11:59PM Ends: Friday December 13, 11:59PM 1 Introduction The purpose of this assignment is to become more familiar

More information

15-213, Spring 2008 Lab Assignment L1: Manipulating Bits Assigned: Jan. 15, Due: Wed., Jan. 30, 11:59PM

15-213, Spring 2008 Lab Assignment L1: Manipulating Bits Assigned: Jan. 15, Due: Wed., Jan. 30, 11:59PM 15-213, Spring 2008 Lab Assignment L1: Manipulating Bits Assigned: Jan. 15, Due: Wed., Jan. 30, 11:59PM Randy Bryant (Randy.Bryant@cs.cmu.edu) is the lead person for this assignment. 1 Introduction The

More information

CS 356, Fall 2018 Data Lab (Part 1): Manipulating Bits Due: Wednesday, Sep. 5, 11:59PM

CS 356, Fall 2018 Data Lab (Part 1): Manipulating Bits Due: Wednesday, Sep. 5, 11:59PM CS 356, Fall 2018 Data Lab (Part 1): Manipulating Bits Due: Wednesday, Sep. 5, 11:59PM 1 Introduction The purpose of this assignment is to become more familiar with bit-level representations of integers

More information

ECEn 424 Data Lab: Manipulating Bits

ECEn 424 Data Lab: Manipulating Bits ECEn 424 Data Lab: Manipulating Bits 1 Introduction The purpose of this assignment is to become more familiar with bit-level representations of integers and floating point numbers. You ll do this by solving

More information

CS 2505 Fall 2018 Data Lab: Data and Bitwise Operations Assigned: November 1 Due: Friday November 30, 23:59 Ends: Friday November 30, 23:59

CS 2505 Fall 2018 Data Lab: Data and Bitwise Operations Assigned: November 1 Due: Friday November 30, 23:59 Ends: Friday November 30, 23:59 CS 2505 Fall 2018 Data Lab: Data and Bitwise Operations Assigned: November 1 Due: Friday November 30, 23:59 Ends: Friday November 30, 23:59 1 Introduction The purpose of this assignment is to become more

More information

CS 356, Fall 2018 Data Lab (Part 2): Manipulating Bits Due: Mon, Sep. 17, 11:59PM

CS 356, Fall 2018 Data Lab (Part 2): Manipulating Bits Due: Mon, Sep. 17, 11:59PM CS 356, Fall 2018 Data Lab (Part 2): Manipulating Bits Due: Mon, Sep. 17, 11:59PM 1 Introduction This second part of the data lab continues on bit-level manipulations and 2 s complement arithmetic as well

More information

Project Data: Manipulating Bits

Project Data: Manipulating Bits CSCI0330 Intro Computer Systems Doeppner Project Data: Manipulating Bits Due: September 26, 2018 at 11:59pm 1 Introduction 1 2 Assignment 1 2.1 Collaboration 3 2.2 TA Hours 3 3 The Puzzles 3 3.1 Bit Manipulations

More information

CSC 2400: Bit Manipulation Assignment

CSC 2400: Bit Manipulation Assignment CSC 2400: Bit Manipulation Assignment The purpose of this assignment is to enhance your skills on bit-level representations and manipulations. You'll do this by solving a series of programming ``puzzles.''

More information

ENCE 3241 Data Lab. 60 points Due February 19, 2010, by 11:59 PM

ENCE 3241 Data Lab. 60 points Due February 19, 2010, by 11:59 PM 0 Introduction ENCE 3241 Data Lab 60 points Due February 19, 2010, by 11:59 PM The purpose of this assignment is for you to become more familiar with bit-level representations and manipulations. You ll

More information

15213 Recitation 2: Floating Point

15213 Recitation 2: Floating Point 15213 Recitation 2: Floating Point 1 Introduction This handout will introduce and test your knowledge of the floating point representation of real numbers, as defined by the IEEE standard. This information

More information

15213 Recitation Section C

15213 Recitation Section C 15213 Recitation Section C Outline Sept. 9, 2002 Introduction Unix and C Playing with Bits Practice Problems Introducing Myself Try to pronounce my name: My office hour: Wed 2-3pm, WeH 8019 Contact: Email:

More information

CS356: Discussion #2 Integer Operations. Marco Paolieri

CS356: Discussion #2 Integer Operations. Marco Paolieri CS356: Discussion #2 Integer Operations Marco Paolieri (paolieri@usc.edu) Integers in C (64-bit architecture) Type Size (bytes) Unsigned Range Signed Range char 1 0 to 255-128 to 127 short 2 0 to 65535-32,768

More information

Computer Organization & Systems Exam I Example Questions

Computer Organization & Systems Exam I Example Questions Computer Organization & Systems Exam I Example Questions 1. Pointer Question. Write a function char *circle(char *str) that receives a character pointer (which points to an array that is in standard C

More information

FALL 2017 CSCI 304 LAB1 (Due on Sep-19, 11:59:59pm)

FALL 2017 CSCI 304 LAB1 (Due on Sep-19, 11:59:59pm) FALL 2017 CSCI 304 LAB1 (Due on Sep-19, 11:59:59pm) Objectives: Debugger Standard I/O Arithmetic statements Conditional structures Looping structures File I/O Strings Pointers Functions Structures Important

More information

CSE 351: The Hardware/Software Interface. Section 2 Integer representations, two s complement, and bitwise operators

CSE 351: The Hardware/Software Interface. Section 2 Integer representations, two s complement, and bitwise operators CSE 351: The Hardware/Software Interface Section 2 Integer representations, two s complement, and bitwise operators Integer representations In addition to decimal notation, it s important to be able to

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

SPRING 2017 CSCI 304 LAB1 (Due on Feb-14, 11:59:59pm)

SPRING 2017 CSCI 304 LAB1 (Due on Feb-14, 11:59:59pm) SPRING 2017 CSCI 304 LAB1 (Due on Feb-14, 11:59:59pm) Objectives: Debugger Standard I/O Arithmetic statements IF/Switch structures Looping structures File I/O Strings Pointers Functions Structures Important

More information

CS33 Project Gear Up. Data

CS33 Project Gear Up. Data CS33 Project Gear Up Data Project Overview You will be solving a series of puzzles using your knowledge of data representations. IMPORTANT: Collaboration This project has a different collaboration policy

More information

Exercise Session 2 Systems Programming and Computer Architecture

Exercise Session 2 Systems Programming and Computer Architecture Systems Group Department of Computer Science ETH Zürich Exercise Session 2 Systems Programming and Computer Architecture Herbstsemester 216 Agenda Linux vs. Windows Working with SVN Exercise 1: bitcount()

More information

Beginning C Programming for Engineers

Beginning C Programming for Engineers Beginning Programming for Engineers R. Lindsay Todd Lecture 6: Bit Operations R. Lindsay Todd () Beginning Programming for Engineers Beg 6 1 / 32 Outline Outline 1 Place Value Octal Hexadecimal Binary

More information

LAB A Translating Data to Binary

LAB A Translating Data to Binary LAB A Translating Data to Binary Create a directory for this lab and perform in it the following groups of tasks: LabA1.java 1. Write the Java app LabA1 that takes an int via a command-line argument args[0]

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

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

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

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

CSCI 2212: Intermediate Programming / C Chapter 15

CSCI 2212: Intermediate Programming / C Chapter 15 ... /34 CSCI 222: Intermediate Programming / C Chapter 5 Alice E. Fischer October 9 and 2, 25 ... 2/34 Outline Integer Representations Binary Integers Integer Types Bit Operations Applying Bit Operations

More information

Lecture 13 Bit Operations

Lecture 13 Bit Operations Lecture 13 Bit Operations C is a powerful language as it provides the programmer with many operations for bit manipulation. Data can be accessed at the bit level to make operations more efficient. As you

More information

ANITA S SUPER AWESOME RECITATION SLIDES. 15/18-213: Introduction to Computer Systems Bit Logic and Floating Point, 27 January 2014 Anita Zhang

ANITA S SUPER AWESOME RECITATION SLIDES. 15/18-213: Introduction to Computer Systems Bit Logic and Floating Point, 27 January 2014 Anita Zhang ANITA S SUPER AWESOME RECITATION SLIDES 15/18-213: Introduction to Computer Systems Bit Logic and Floating Point, 27 January 2014 Anita Zhang WELCOME TO THE SPRING EDITION Data Lab due Thursday, 30 Jan

More information

Description Hex M E V smallest value > largest denormalized negative infinity number with hex representation 3BB0 ---

Description Hex M E V smallest value > largest denormalized negative infinity number with hex representation 3BB0 --- CSE2421 HOMEWORK #2 DUE DATE: MONDAY 11/5 11:59pm PROBLEM 2.84 Given a floating-point format with a k-bit exponent and an n-bit fraction, write formulas for the exponent E, significand M, the fraction

More information

Systems Programming and Computer Architecture ( ) Exercise Session 01 Data Lab

Systems Programming and Computer Architecture ( ) Exercise Session 01 Data Lab Systems Programming and Computer Architecture (252-0061-00) Exercise Session 01 Data Lab 1 Goal Get familiar with bit level representations, C and Linux Thursday, September 22, 2016 Systems Programming

More information

Bits, Words, and Integers

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

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

Chapter 2. Data Representation in Computer Systems

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

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

Lecture 17 Bit Operations

Lecture 17 Bit Operations Lecture 17 Bit Operations In this lecture Background Left Shifting Negative Numbers, one s complement and two s complement Right Shifting Bit Operators Masking the Bits Getting the Bits Setting the Bits

More information

CHAPTER 1 Numerical Representation

CHAPTER 1 Numerical Representation CHAPTER 1 Numerical Representation To process a signal digitally, it must be represented in a digital format. This point may seem obvious, but it turns out that there are a number of different ways to

More information

Programming Studio #1 ECE 190

Programming Studio #1 ECE 190 Programming Studio #1 ECE 190 Programming Studio #1 Announcements Recitation Binary representation, hexadecimal notation floating point representation, 2 s complement In Studio Assignment Introduction

More information

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

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

More information

DEPARTMENT OF MATHS, MJ COLLEGE

DEPARTMENT OF MATHS, MJ COLLEGE T. Y. B.Sc. Mathematics MTH- 356 (A) : Programming in C Unit 1 : Basic Concepts Syllabus : Introduction, Character set, C token, Keywords, Constants, Variables, Data types, Symbolic constants, Over flow,

More information

Chapter 3: Operators, Expressions and Type Conversion

Chapter 3: Operators, Expressions and Type Conversion 101 Chapter 3 Operators, Expressions and Type Conversion Chapter 3: Operators, Expressions and Type Conversion Objectives To use basic arithmetic operators. To use increment and decrement operators. To

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

COMP Overview of Tutorial #2

COMP Overview of Tutorial #2 COMP 1402 Winter 2008 Tutorial #2 Overview of Tutorial #2 Number representation basics Binary conversions Octal conversions Hexadecimal conversions Signed numbers (signed magnitude, one s and two s complement,

More information

CS 429H, Spring 2012 Optimizing the Performance of a Pipelined Processor Assigned: March 26, Due: April 19, 11:59PM

CS 429H, Spring 2012 Optimizing the Performance of a Pipelined Processor Assigned: March 26, Due: April 19, 11:59PM CS 429H, Spring 2012 Optimizing the Performance of a Pipelined Processor Assigned: March 26, Due: April 19, 11:59PM 1 Introduction In this lab, you will learn about the design and implementation of a pipelined

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

Computer Systems Programming. Practice Midterm. Name:

Computer Systems Programming. Practice Midterm. Name: Computer Systems Programming Practice Midterm Name: 1. (4 pts) (K&R Ch 1-4) What is the output of the following C code? main() { int i = 6; int j = -35; printf( %d %d\n,i++, ++j); i = i >

More information

Binary Representations and Arithmetic

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

More information

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

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

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

Programming Studio #1 ECE 190

Programming Studio #1 ECE 190 Programming Studio #1 ECE 190 Programming Studio #1 Announcements In Studio Assignment Introduction to Linux Command-Line Operations Recitation Floating Point Representation Binary & Hexadecimal 2 s Complement

More information

Digital Design and Computer Architecture Harris and Harris, J. Spjut Elsevier, 2007

Digital Design and Computer Architecture Harris and Harris, J. Spjut Elsevier, 2007 Digital Design and Computer Architecture Harris and Harris, J. Spjut Elsevier, 2007 Lab 8: MIPS ARM Assembly Language Programming Introduction In this lab, you will learn to write ARM assembly language

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

CS Programming In C

CS Programming In C CS 24000 - Programming In C Week Two: Basic C Program Organization and Data Types Zhiyuan Li Department of Computer Science Purdue University, USA 2 int main() { } return 0; The Simplest C Program C programs

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

Number representations

Number representations Number representations Number bases Three number bases are of interest: Binary, Octal and Hexadecimal. We look briefly at conversions among them and between each of them and decimal. Binary Base-two, or

More information

Recap from Last Time. CSE 2021: Computer Organization. It s All about Numbers! 5/12/2011. Text Pictures Video clips Audio

Recap from Last Time. CSE 2021: Computer Organization. It s All about Numbers! 5/12/2011. Text Pictures Video clips Audio CSE 2021: Computer Organization Recap from Last Time load from disk High-Level Program Lecture-2(a) Data Translation Binary patterns, signed and unsigned integers Today s topic Data Translation Code Translation

More information

Introduction to Computer Engineering (E114)

Introduction to Computer Engineering (E114) Introduction to Computer Engineering (E114) Lab 7: Floating-Point Addition Introduction In this lab, you will write a MIPS assembly language function that performs floatingpoint addition You will then

More information

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

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

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

Processor. Lecture #2 Number Rep & Intro to C classic components of all computers Control Datapath Memory Input Output

Processor. Lecture #2 Number Rep & Intro to C classic components of all computers Control Datapath Memory Input Output CS61C L2 Number Representation & Introduction to C (1) insteecsberkeleyedu/~cs61c CS61C : Machine Structures Lecture #2 Number Rep & Intro to C Scott Beamer Instructor 2007-06-26 Review Continued rapid

More information

Embedded Systems - FS 2018

Embedded Systems - FS 2018 Institut für Technische Informatik und Kommunikationsnetze Prof. L. Thiele Embedded Systems - FS 2018 Lab 0 Date : 28.2.2018 Prelab Filling the gaps Goals of this Lab You are expected to be already familiar

More information

Data Representation 1

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

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

CS 241 Data Organization Binary

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

More information

4 Operations On Data 4.1. Foundations of Computer Science Cengage Learning

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

More information

1010 2?= ?= CS 64 Lecture 2 Data Representation. Decimal Numbers: Base 10. Reading: FLD Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

1010 2?= ?= CS 64 Lecture 2 Data Representation. Decimal Numbers: Base 10. Reading: FLD Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 CS 64 Lecture 2 Data Representation Reading: FLD 1.2-1.4 Decimal Numbers: Base 10 Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Example: 3271 = (3x10 3 ) + (2x10 2 ) + (7x10 1 ) + (1x10 0 ) 1010 10?= 1010 2?= 1

More information

Expression and Operator

Expression and Operator Expression and Operator Examples: Two types: Expressions and Operators 3 + 5; x; x=0; x=x+1; printf("%d",x); Function calls The expressions formed by data and operators An expression in C usually has a

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

Compiler Design: Lab 3 Fall 2009

Compiler Design: Lab 3 Fall 2009 15-411 Compiler Design: Lab 3 Fall 2009 Instructor: Frank Pfenning TAs: Ruy Ley-Wild and Miguel Silva Test Programs Due: 11:59pm, Thursday, October 8, 2009 Compilers Due: 11:59pm, Thursday, October 15,

More information

CS356: Discussion #3 Floating-Point Operations. Marco Paolieri

CS356: Discussion #3 Floating-Point Operations. Marco Paolieri CS356: Discussion #3 Floating-Point Operations Marco Paolieri (paolieri@usc.edu) Today s Agenda More Integer operations exercise Floating-Point operations exercise for Lab 2 Data Lab 2: What to implement

More information

Signed Binary Numbers

Signed Binary Numbers Signed Binary Numbers Unsigned Binary Numbers We write numbers with as many digits as we need: 0, 99, 65536, 15000, 1979, However, memory locations and CPU registers always hold a constant, fixed number

More information

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

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

More information

Lab 03 - x86-64: atoi

Lab 03 - x86-64: atoi CSCI0330 Intro Computer Systems Doeppner Lab 03 - x86-64: atoi Due: October 1, 2017 at 4pm 1 Introduction 1 2 Assignment 1 2.1 Algorithm 2 3 Assembling and Testing 3 3.1 A Text Editor, Makefile, and gdb

More information

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS Aleksandar Milenković The LaCASA Laboratory, ECE Department, The University of Alabama in Huntsville Email: milenka@uah.edu Web:

More information

Computer Organisation CS303

Computer Organisation CS303 Computer Organisation CS303 Module Period Assignments 1 Day 1 to Day 6 1. Write a program to evaluate the arithmetic statement: X=(A-B + C * (D * E-F))/G + H*K a. Using a general register computer with

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

CSCI 2467, Spring 2018 Class Activity: Two s complement, bitwise and logical operators Monday, February 5

CSCI 2467, Spring 2018 Class Activity: Two s complement, bitwise and logical operators Monday, February 5 CSCI 467, Spring 08 Class Activity: Two s complement, bitwise and logical operators Monday, February 5 Introduction 467 Instructor: M. Toups mtoups@cs.uno.edu In this activity you will practice working

More information

Real Numbers finite subset real numbers floating point numbers Scientific Notation fixed point numbers

Real Numbers finite subset real numbers floating point numbers Scientific Notation fixed point numbers Real Numbers We have been studying integer arithmetic up to this point. We have discovered that a standard computer can represent a finite subset of the infinite set of integers. The range is determined

More information

CS 3843 Final Exam Fall 2012

CS 3843 Final Exam Fall 2012 CS 3843 Final Exam Fall 2012 Name (Last), (First) ID Please indicate your session: Morning Afternoon You may use a calculator and two sheets of notes on this exam, but no other materials and no computer.

More information

C-string format with scanf/printf

C-string format with scanf/printf CSI333 Lecture 4 C-string format with scanf/printf char mycstring[4]; int intvar; scanf("%3s", &intvar ); /*reads up to 3 chars and stores them PLUS \ in the 4-byte var. intvar*/ scanf("%3s", mycstring);

More information

CIS 2107 Computer Systems and Low-Level Programming Fall 2011 Midterm Solutions

CIS 2107 Computer Systems and Low-Level Programming Fall 2011 Midterm Solutions Fall 2011 Name: Page Points Score 1 7 2 10 3 8 4 13 6 17 7 4 8 16 9 15 10 10 Total: 100 Instructions The exam is closed book, closed notes. You may not use a calculator, cell phone, etc. For each of the

More information

Logic, Words, and Integers

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

More information

CS101 Lecture 04: Binary Arithmetic

CS101 Lecture 04: Binary Arithmetic CS101 Lecture 04: Binary Arithmetic Binary Number Addition Two s complement encoding Briefly: real number representation Aaron Stevens (azs@bu.edu) 25 January 2013 What You ll Learn Today Counting in binary

More information

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

l l l l l l l Base 2; each digit is 0 or 1 l Each bit in place i has value 2 i l Binary representation is used in computers 198:211 Computer Architecture Topics: Lecture 8 (W5) Fall 2012 Data representation 2.1 and 2.2 of the book Floating point 2.4 of the book Computer Architecture What do computers do? Manipulate stored information

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

15-213/18-213/15-513, Fall 2017 C Programming Lab: Assessing Your C Programming Skills

15-213/18-213/15-513, Fall 2017 C Programming Lab: Assessing Your C Programming Skills 15-213/18-213/15-513, Fall 2017 C Programming Lab: Assessing Your C Programming Skills 1 Logistics Assigned: Tues., Aug. 29, 2017 Due: Thurs., Sept. 7, 11:59 pm Last possible hand in: Tues., Sept. 7, 11:59

More information

SU 2017 May 18/23 LAB 3 Bitwise operations, Program structures, Functions (pass-by-value), local vs. global variables. Debuggers

SU 2017 May 18/23 LAB 3 Bitwise operations, Program structures, Functions (pass-by-value), local vs. global variables. Debuggers SU 2017 May 18/23 LAB 3 Bitwise operations, Program structures, Functions (pass-by-value), local vs. global variables. Debuggers 1. Problem A Pass-by-value, and trace a program with debugger 1.1 Specification

More information

CIS 2107 Computer Systems and Low-Level Programming Fall 2010 Midterm

CIS 2107 Computer Systems and Low-Level Programming Fall 2010 Midterm Fall 2010 Name: Page Points Score 1 8 2 9 3 11 4 10 5 11 6 1 7 9 8 21 9 10 10 10 Total: 100 Instructions The exam is closed book, closed notes. You may not use a calculator, cell phone, etc. For each of

More information

Introduction to Computing Systems Fall Lab # 3

Introduction to Computing Systems Fall Lab # 3 EE 1301 UMN Introduction to Computing Systems Fall 2013 Lab # 3 Collaboration is encouraged. You may discuss the problems with other students, but you must write up your own solutions, including all your

More information

ISA 563 : Fundamentals of Systems Programming

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

More information

Binary Arithmetic CS 64: Computer Organization and Design Logic Lecture #2 Fall 2018

Binary Arithmetic CS 64: Computer Organization and Design Logic Lecture #2 Fall 2018 Binary Arithmetic CS 64: Computer Organization and Design Logic Lecture #2 Fall 2018 Ziad Matni, Ph.D. Dept. of Computer Science, UCSB Administrative Stuff The class is full I will not be adding more ppl

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

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