Unit 2: Boolean Logic
|
|
- Myra Hamilton
- 5 years ago
- Views:
Transcription
1 AP Computer Science Mr. Haytock Unit 2: Boolean Logic Topics: I. Syllogisms and propositional logic II. Logical operators III. Constructing truth tables IV. Laws of Boolean algebra V. Boolean operations in programming languages VI. Bitwise logical operations Materials: I. Pohl and Shaw ch. IV II. Boolean exercises #1 III. Boolean exercises #2 IV. Boolean exercises #3 V. Challenge Questions VI. Bitwise operations program VII. Full adder specifications VIII. Sample code IX. Review sheet X. Sample Free Response question 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10
11 11
12 12
13 13
14 Boolean Exercises #1 I. The following are compound statements. Find their simple components, and assign a symbol to each. Write them in symbolic form. a. It is hot and it is raining. b. Jack and Jill went up the hill. c. If it is raining or snowing, we will cancel the picnic. II. Let P be Fred is smart and Q be George is smart. Write the following statements in symbolic form. a. Fred is smart and George is stupid. b. Fred and George are both stupid. c. Either Fred is smart or George is stupid. d. It is not true that Fred and George are both stupid. III. Assume that Fred and George are both smart. Which of the above compound statements would be true? 14
15 IV. Let P be Stock prices are high and Q be Stocks are rising. Give a verbal translation for each of the following. a. P ~Q b. ~P ~Q c. ~(P Q) d. ~(~P ~Q) V. Construct a truth table for the following: (P Q) (Q P) VI. Let P be It is raining and Q be It is windy. Translate the following into symbolic form and give a truth table for each: a. If the wind blows then it does not rain. b. The wind blows if and only if it rains. 15
16 Boolean Exercises #2 I. Translate the following sentences into symbolic propositional logic expressions. First, assign a symbol for each primary component, then put it together with the proper symbols. a. The cat is either male or female, but not both. b. Either John is not speaking and Mary is speaking or John is speaking and Mary is speaking. II. Use truth tables to prove that: a) A (B A) is a tautology b) (A B) A B c) A B B A d) (A B) (A B) is a contradiction. e) A (B C) (A B) (A C) f) A (A B) is the same as A 16
17 Boolean Exercises #3 1. The Boolean expression ((isdone input== a ) && input== a ) is equivalent to which of the following expressions? a) isdone b) input== a c) isdone input== a d) isdone && input== a e) 1 (it is always true) 2. The Boolean expression ((degrees < 32 && degrees > 0) && degrees < 32) is equivalent to which of the following expressions? a) degrees < 32 b) degrees > 0 c) degrees < 32 degrees > 0 d) degrees < 32 && degrees > 0 e) 1 (it is always true) 3) The Boolean expression (!(numfiles/4 > 0 inchar > 65)) is equivalent to which of the following expressions? a) numfiles/4 > 0!= inchar > 65 b)!(numfiles/4 > 0) inchar > 65 c) numfiles/4 > 0 && inchar > 65 d)!(numfiles/4 > 0)!(inChar > 65) e)!(numfiles/4 > 0) &&!(inchar > 65) 4) The Boolean expression (!((numstudents < numfaculty) && (numstaff > numcoaches))) is equivalent to which of the following expressions? a) (numstudents < numfaculty) (numstaff > numcoaches) b) (numstudents >= numfaculty) && (numstaff <= numcoaches) c) (numstudents >= numfaculty) ( numstaff <= numcoaches) d) (numstudents > numfaculty) && (numstaff < numcoaches) e) (numstudents > numfaculty) (numstaff < numcoaches) 17
18 5) What is the effect of the following short Java code fragment? String command = A ; do System.out.println(command); command = Keyboard.readString(); while (!command.equals( q )!command.equals( Q )); a. The loop will terminate if the string q is entered or if the string Q is entered. b. The loop will terminate only if the string q is entered. c. The loop will terminate only if the string Q is entered. d. The loop will never terminate an infinite loop will result. e. The loop will terminate after its first iteration no matter what is entered. 6. Given the Boolean variables P and Q what is an equivalent statement to the following? if ( (P &&!Q) (!P && Q) ) a. if (true) b. if (false) c. if (P Q) d. if (P ^ Q) e. if (P && Q) 7. In Java, what is the result of the following: a. true b. false c. 3 d. 7 e In Java, what is the result of the following: 11 ^ 12 a. true b. false c. 3 d. 7 e
19 Boolean Algebra Challenge Problems 1. Simplify: ( A B AC )( C B ) A 2. Simplify: AB( C A) B( A BC) 3. The two arguments in the expression below are hexadecimal representations of bit strings that are 12-bits long. Evaluate the expression and express your answer as a 3-digit hexadecimal string. A26 XOR 7B5 4. List all the values of X (a 5-bit string) that make the expression TRUE. ((LCIRC-3 (X AND 10010)) OR (RSHIFT-2 (X AND 01101)) = How many ordered triples make the following circuit TRUE? A B C 19
20 AP Computer Science Mr. Haytock Programming Assignment No. 2: Bitwise Command Interpreter Specifications: As we have been discussing in class, at the hardware level, a computer is constantly performing calculations by turning bits on and off. One of the ways that the computer organizes these switches into a recognizable calculation is to control the flow of electricity by means of gates to perform Boolean logic. We have seen this on the board, but as the old Chinese proverb says: I hear and I forget; I see and I remember; I do and I understand. Write a program that interprets a list of bitwise Boolean operations and performs them on the data given. Your program should evaluate bitwise and, or, exclusive or, not, left shift, and right shift. Input: Your input will come from a file specified by the user (read the file name at run-time). The file will contain an indeterminate number of lines. The program will quit when it reaches a blank line or a sentinel value (e.g. q to quit). Each line will contain a command following by one or two decimal numbers separated by a single space. A few sample input lines could be as follows: & & 15 7 ^ > 44 2 q Your output will go to a file called bitwiseoutput.txt. For the input file given above, the output file would be: 12 AND 10 ==> 8 12 OR 20 ==> AND 7 ==> 7 15 XOR 19 ==> SHR by 2 bits ==> 11 quitting Submission Format: Hand in to me a printout of your source code files, a printout of your input and output files, and concluding reflections. Also turn in an electronic copy of these files. The project is due:,. I ll accept it up until 3 PM before I count it late. Be sure to document your work well with appropriate and useful comments! II. Design Phase For full credit you must properly decompose your program into methods. A framework of the driver program will be given to you. 20
21 III. Implementation Use the built-in bitwise operators for this project. &: and : or ^: exclusive or ~: complement (bit-wise not) >>: shift right <<: shift left IV.Testing: Choose input which will effectively test your program. Determine whether or not the results of each operation are what you expected. When you are finished, write a short (perhaps half a page) summary of which commands did / did not do what you expected. - Can you explain the results of the shifting commands? - Can you explain the results of the complement (not) operation? - What kinds of common exceptions should be handled? Be sure that you document how your program handles all possible cases. 21
22 /* NAME: DATE: Description: Bitwise operator testing template. */ import cs.ssa.*; // imports the file I/O classes import cs1.keyboard; // for keyboard I/O class BitwiseOperatorTester static InFile infile; static OutFile outfile; static public void main(string[] args) char command = ; prepio(); command = infile.read(); while (command!= q ) processcommand(command); command = infile.read(); infile.close(); outfile.close(); static public void prepio() // prepares the input and output streams String filename; System.out.println("Please enter file name: "); filename = Keyboard.readString(); infile = new InFile(fileName); outfile = new OutFile( bitwiseoutput.txt ); static public void processcommand(char command) // Uses only the first character of the command switch (command) case '&': do_and(); break; case ' ': do_or(); break; case '^': do_xor(); break; case '~': do_not(); break; case '>': do_shr(); break; case '<': do_shl(); break; static private void do_and() /* your code should output a line according to the specifications */ 22
23 AP Computer Science Mr. Haytock Programming Assignment No. 2: The Full Adder Specifications: As we have been discussing in class, at the hardware level, a computer is constantly performing calculations by turning bits on and off. One of the ways that the computer organizes these switches into a recognizable calculation is to control the flow of electricity by means of gates to perform Boolean logic. We have seen this on the board, but as the old Chinese proverb says: I hear and I forget; I see and I remember; I do and I understand. Your program will simulate adding with logic gates. Input a list of pairs of nybbles (4 bit numbers). Add each pair of numbers and get the result. To simulate hardware gates, restrict your program to accomplishing this only by means of bitwise operations. I/O option 1: Your input may come from a file specified by the user (read the file name at runtime). The file will contain an indeterminate number of lines. The program will quit when it reaches a blank line or a sentinel value (e.g. q to quit). Each line will contain two 4-bit binary numbers separated by a single space. A few sample input lines could be as follows: Your output will go to a file called adder.out. This file will contain the results of adding the numbers from the input file. For the input file given above, the output file would be: Num1: 1100 Num2: 0011 Result: 1111 Num1: 0011 Num2: 0010 Result: 0101 Num1: 0011 Num2: 0001 Result: 0100 Num1: 0011 Num2: 1110 Result: 0001 I/O option 2: Create a GUI (graphical user interface). A list of four images are to be drawn across the screen in a regular pattern for each number. The images 1.gif and 0.gif are available to you each one is 50 x 50 pixels. Use the mouse to determine whether or not a number has been clicked. A given number should switch between 0 and 1 when clicked. Finally, add a go button that will perform the arithmetic. Hand in to me a printout of your source code files, a printout of your input and output files or screen shots with test data, and concluding reflections. Also turn in an electronic copy of these files. The project is due:,. I ll accept it up until 3 PM before I count it late. Be sure to document your work well with appropriate and useful comments! 23
24 II. Design Phase Before implementing, consider everything that needs to be accomplished in this program. For full credit, you must properly decompose the program into methods. A framework of the adder class will be given to you. What algorithm performs the addition? Use a full adder circuit as discussed in class. What inputs will each method need, and what should they output? If using a GUI, how should the screen be partitioned? Diagram it ahead of time. III. Implementation Store your two input numbers as type boolean. From there, the addition feature should be accomplished by means of Boolean tests. For full credit, you must utilize at least one booleanreturning method. If you are using a GUI, you will need to refer to the SSAWindow class features. Two of the important ones you will need include the drawimage command, requiring a file name and an (x,y) pair for parameters. The second is the mousepressed method, overridden from the parent class, which requires an (x,y) pair of parameters. See the sample code for a framework. IV.Testing Choose input which will effectively test your program. Try numbers that are simple, numbers that are complicated, and numbers that create overflow. - What kinds of data combinations do you need to test in order to know whether your program works correctly? - What kinds of common exceptions should be handled? Be sure that you document how your program handles all possible cases. 24
25 /* Name: Date: Description: Framework for AdderDriver */ import cs.ssa.*; class AdderDriver static public void main(string[] args) BitWindow mywindow = new BitWindow(600, 500); class BitWindow extends SSAWindow private final int XLEFT = 50; // set screen constants private final int ROW1YTOP = 50; private final int IMAGESIZE = 50; private boolean bit0a, bit1a, bit2a, bit3a; private boolean bit0b, bit1b, bit2b, bit3b; private boolean bit0c, bit1c, bit2c, bit3c; public BitWindow(int width, int height) super(width, height); drawscreen(); // initialize window and values private void drawscreen() /* Draws the icons representing the trues and falses stored in our booleans. */ // erase previous screen // draw an image for the button to perform the addition // draw icons for the input and output numbers public void add() /* Use a FullAdder set of logic operations to perform the addition. */ public void mousepressed(int xp, int yp) /* The header for "mousepressed" must be written exactly as it is. This is an overridden method from the parent "SSAWindow" class. */ System.out.println("X: " + xp + " Y: " + yp); // for testing purposes if (goclicked(xp, yp)) add(); else lookforbutton(xp, yp); 25
26 drawscreen(); // re-draw the screen in case things have changed public boolean goclicked(int x, int y) /* Test to see if the mouse coordinates overlap the "go" button area. */ public void lookforbutton(int x, int y) /* Try to determine if the mouse coordinates overlap the area of any of the input bit areas. */ int row; int column; row = (y - ROW1YTOP) / IMAGESIZE; // row may be 0, 1 or out of bounds column = (x - XLEFT) / IMAGESIZE; // column may be or out of bounds if (row == 0) // look for bit in first number if (column == 0) // alternatively use a switch structure bit0a =!bit0a; // flip value between true / false else... else if (row == 1) // look for bit in second number... 26
27 AP Computer Science Mr. Haytock Review for Test #1: Boolean Logic I. Review Exercises: A. Symbolic Notation: Be sure that you understand how to find the elementary propositions in an English sentence and how to put them together to make a symbolic expression. Translate the following English sentences into symbolic form: a. John and Mary are both speaking or John and Mary are not both speaking. b. John and Mary are not both speaking if and only if John is not speaking or Mary is not speaking. B. Truth Tables: Be sure that you can set up truth tables and use them to show the possible values for given expressions. You should also be able to use truth tables to show certain tautologies and contradictions. Set up a truth table for each of the following: a. Q ~Q P b. P ~ Q R C. Boolean Algebra: Understand and be able to apply the major laws of Boolean Algebra. For practice, choose two of them and draw up a truth table for them. a. b. 27
28 D. Boolean Logic in Programming: Evaluate each of the Java expressions below, given the following information: thereareerrors = true total = 88 earned = 65 a.!thereareerrors total <= earned b. thereareerrors &&!(total <= earned (total - earned) > 0) c. thereareerrors == ((total / earned) > 0) d. (!thereareerrors && total == 88) E. Terms: Provide definitions for the following terms: a. Tautology b. Contradiction c. Short-circuit evaluation d. Precedence of operators e. Syllogistic argument F. Combinational Logic Circuits: Be able to recognize the symbols for AND gates, OR gates, etc. and how to put them together for truth values. Understand Bitwise operations. a. Draw a symbolic circuit diagram for the expression: c = ~(a & (b!a)) b. What are the results of the following bit-wise operations? 1. 7 & & ^ 14 II. Programming: review the full adder program. Be sure that you understand the project specifications, design, and implementation. III. Lecture Material: Anything I ve said in class is fair game. IV. Reading Material: Review excerpts from Pohl and Shaw on Boolean Algebra. 28
29 AP Computer Science Practice Free Response Solve the problem below. Write your solution using clear, correct Java code. Circuitry Coding: Write a method that correctly simulates the integrated circuit that is described by the gate diagram below. You are to write the method header, naming the method circuitdiagram. It should return a Boolean value and receive three Boolean type parameters (you may name them A, B, and C ). You do not have to simplify the expression, although you can if you wish. A B C An example of how this method is to be called might as follows: if (circuitdiagram(true, true, false)) beginmethod 29
30 30
Logic Gates and Boolean Algebra ENT263
Logic Gates and Boolean Algebra ENT263 Logic Gates and Boolean Algebra Now that we understand the concept of binary numbers, we will study ways of describing how systems using binary logic levels make
More informationCS 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 informationEE292: Fundamentals of ECE
EE292: Fundamentals of ECE Fall 2012 TTh 10:00-11:15 SEB 1242 Lecture 22 121115 http://www.ee.unlv.edu/~b1morris/ee292/ 2 Outline Review Binary Number Representation Binary Arithmetic Combinatorial Logic
More informationBinary Adders: Half Adders and Full Adders
Binary Adders: Half Adders and Full Adders In this set of slides, we present the two basic types of adders: 1. Half adders, and 2. Full adders. Each type of adder functions to add two binary bits. In order
More informationJAVA OPERATORS GENERAL
JAVA OPERATORS GENERAL Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups: Arithmetic Operators Relational Operators Bitwise Operators
More informationRead this before starting!
Points missed: Student's Name: Total score: /100 points East Tennessee State University Department of Computer and Information Sciences CSCI 2150 (Tarnoff) Computer Organization TEST 1 for Spring Semester,
More informationQUESTION BANK FOR TEST
CSCI 2121 Computer Organization and Assembly Language PRACTICE QUESTION BANK FOR TEST 1 Note: This represents a sample set. Please study all the topics from the lecture notes. Question 1. Multiple Choice
More informationBits and Bytes. How do computers compute?
Bits and Bytes How do computers compute? Representing Data All data can be represented with: 1s and 0s on/of true/false Numbers? Five volunteers... Binary Numbers Positional Notation Binary numbers use
More informationENGIN 112 Intro to Electrical and Computer Engineering
ENGIN 2 Intro to Electrical and Computer Engineering Lecture 5 Boolean Algebra Overview Logic functions with s and s Building digital circuitry Truth tables Logic symbols and waveforms Boolean algebra
More informationSYNERGY INSTITUTE OF ENGINEERING & TECHNOLOGY,DHENKANAL LECTURE NOTES ON DIGITAL ELECTRONICS CIRCUIT(SUBJECT CODE:PCEC4202)
Lecture No:5 Boolean Expressions and Definitions Boolean Algebra Boolean Algebra is used to analyze and simplify the digital (logic) circuits. It uses only the binary numbers i.e. 0 and 1. It is also called
More informationArithmetic-logic units
Arithmetic-logic units An arithmetic-logic unit, or ALU, performs many different arithmetic and logic operations. The ALU is the heart of a processor you could say that everything else in the CPU is there
More informationCSE 20 DISCRETE MATH. Fall
CSE 20 DISCRETE MATH Fall 2017 http://cseweb.ucsd.edu/classes/fa17/cse20-ab/ Final exam The final exam is Saturday December 16 11:30am-2:30pm. Lecture A will take the exam in Lecture B will take the exam
More informationRead this before starting!
Points missed: Student's Name: Total score: /100 points East Tennessee State University Department of Computer and Information Sciences CSCI 2150 (Tarnoff) Computer Organization TEST 1 for Spring Semester,
More informationCPSC 121 Some Sample Questions for the Final Exam Tuesday, April 15, 2014, 8:30AM
CPSC 121 Some Sample Questions for the Final Exam Tuesday, April 15, 2014, 8:30AM Name: Student ID: Signature: Section (circle one): George Steve Your signature acknowledges your understanding of and agreement
More informationBasic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators. JAVA Standard Edition
Basic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators JAVA Standard Edition Java - Basic Operators Java provides a rich set of operators to manipulate variables.
More informationCS2630: Computer Organization Homework 1 Bits, bytes, and memory organization Due January 25, 2017, 11:59pm
CS2630: Computer Organization Homework 1 Bits, bytes, and memory organization Due January 25, 2017, 11:59pm Instructions: Show your work. Correct answers with no work will not receive full credit. Whether
More informationProf. Navrati Saxena TA: Rochak Sachan
JAVA Prof. Navrati Saxena TA: Rochak Sachan Operators Operator Arithmetic Relational Logical Bitwise 1. Arithmetic Operators are used in mathematical expressions. S.N. 0 Operator Result 1. + Addition 6.
More information9/19/12. Why Study Discrete Math? What is discrete? Sets (Rosen, Chapter 2) can be described by discrete math TOPICS
What is discrete? Sets (Rosen, Chapter 2) TOPICS Discrete math Set Definition Set Operations Tuples Consisting of distinct or unconnected elements, not continuous (calculus) Helps us in Computer Science
More informationRead this before starting!
Points missed: Student's Name: Total score: /100 points East Tennessee State University Department of Computer and Information Sciences CSCI 2150 (Tarnoff) Computer Organization TEST 1 for Spring Semester,
More informationWhy 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 informationCOMPUTER SCIENCE. Paper 1
COMPUTER SCIENCE Paper 1 (THEORY) Three hours (Candidates are allowed additional 15 minutes for only reading the paper. They must NOT start writing during this time) ----------------------------------------------------------------------------------------------------------------------------------
More informationCOSC 243. Data Representation 3. Lecture 3 - Data Representation 3 1. COSC 243 (Computer Architecture)
COSC 243 Data Representation 3 Lecture 3 - Data Representation 3 1 Data Representation Test Material Lectures 1, 2, and 3 Tutorials 1b, 2a, and 2b During Tutorial a Next Week 12 th and 13 th March If you
More informationPropositional Calculus. Math Foundations of Computer Science
Propositional Calculus Math Foundations of Computer Science Propositional Calculus Objective: To provide students with the concepts and techniques from propositional calculus so that they can use it to
More informationfalse, import, new 1 class Lecture2 { 2 3 "Data types, Variables, and Operators" 4
1 class Lecture2 { 2 3 "Data types, Variables, and Operators" 4 5 } 6 7 // Keywords: 8 byte, short, int, long, char, float, double, boolean, true, false, import, new Zheng-Liang Lu Java Programming 44
More informationLecture (04) Boolean Algebra and Logic Gates
Lecture (4) Boolean Algebra and Logic Gates By: Dr. Ahmed ElShafee ١ Dr. Ahmed ElShafee, ACU : Spring 26, Logic Design Boolean algebra properties basic assumptions and properties: Closure law A set S is
More informationLecture (04) Boolean Algebra and Logic Gates By: Dr. Ahmed ElShafee
Lecture (4) Boolean Algebra and Logic Gates By: Dr. Ahmed ElShafee Boolean algebra properties basic assumptions and properties: Closure law A set S is closed with respect to a binary operator, for every
More informationConcepts Review. 2. A program is the implementation of an algorithm in a particular computer language, like C and C++.
Concepts Review 1. An algorithm is a sequence of steps to solve a problem. 2. A program is the implementation of an algorithm in a particular computer language, like C and C++. 3. A flowchart is the graphical
More informationJava provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups:
Basic Operators Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups: Arithmetic Operators Relational Operators Bitwise Operators
More informationPage 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 informationThis podcast will demonstrate a logical approach as to how a computer adds through logical gates.
This podcast will demonstrate a logical approach as to how a computer adds through logical gates. A computer is a programmable machine that receives input, stores and manipulates data, and provides output
More informationCSC 220: Computer Organization Unit 10 Arithmetic-logic units
College of Computer and Information Sciences Department of Computer Science CSC 220: Computer Organization Unit 10 Arithmetic-logic units 1 Remember: 2 Arithmetic-logic units An arithmetic-logic unit,
More informationData 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 information1. Boolean algebra. [6] 2. Constructing a circuit. [4] 3. Number representation [4] 4. Adders [4] 5. ALU [2] 6. Software [4]
Family Name:.......................... Other Names:.......................... ID Number:.......................... ENGR101: Test 4 May 2009 Instructions Time allowed: 45 minutes. There are 45 marks in
More informationUnit 5: Recursive Thinking
AP Computer Science Mr. Haytock Unit 5: Recursive Thinking Topics: I. Recursion II. Computational limits III. Recursion in graphics Materials: I. Hein ch. 3.2 II. Rawlins: Towers of Hanoi III. Lewis &
More informationBoolean Algebra & Digital Logic
Boolean Algebra & Digital Logic Boolean algebra was developed by the Englishman George Boole, who published the basic principles in the 1854 treatise An Investigation of the Laws of Thought on Which to
More information2. BOOLEAN ALGEBRA 2.1 INTRODUCTION
2. BOOLEAN ALGEBRA 2.1 INTRODUCTION In the previous chapter, we introduced binary numbers and binary arithmetic. As you saw in binary arithmetic and in the handling of floating-point numbers, there is
More informationChapter 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 informationCSE 20 DISCRETE MATH. Winter
CSE 20 DISCRETE MATH Winter 2017 http://cseweb.ucsd.edu/classes/wi17/cse20-ab/ Final exam The final exam is Saturday March 18 8am-11am. Lecture A will take the exam in GH 242 Lecture B will take the exam
More informationBits, 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 informationLe L c e t c ur u e e 2 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Variables Operators
Course Name: Advanced Java Lecture 2 Topics to be covered Variables Operators Variables -Introduction A variables can be considered as a name given to the location in memory where values are stored. One
More informationfalse, import, new 1 class Lecture2 { 2 3 "Data types, Variables, and Operators" 4
1 class Lecture2 { 2 3 "Data types, Variables, and Operators" 4 5 } 6 7 // Keywords: 8 byte, short, int, long, char, float, double, boolean, true, false, import, new Zheng-Liang Lu Java Programming 44
More informationRead this before starting!
Points missed: Student's Name: Total score: /100 points East Tennessee State University Department of Computer and Information Sciences CSCI 2150 (Tarnoff) Computer Organization TEST 1 for Fall Semester,
More informationBefore Class Install SDCC Instructions in Installing_SiLabs-SDCC- Drivers document. Solutions to Number Systems Worksheet. Announcements.
August 15, 2016 Before Class Install SDCC Instructions in Installing_SiLabs-SDCC- Drivers document Install SiLabs Instructions in Installing_SiLabs-SDCC- Drivers document Install SecureCRT On LMS, also
More informationWhy 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 informationECE 550D Fundamentals of Computer Systems and Engineering. Fall 2017
ECE 550D Fundamentals of Computer Systems and Engineering Fall 2017 Combinational Logic Prof. John Board Duke University Slides are derived from work by Profs. Tyler Bletsch and Andrew Hilton (Duke) Last
More informationThe Arithmetic Operators. Unary Operators. Relational Operators. Examples of use of ++ and
The Arithmetic Operators The arithmetic operators refer to the standard mathematical operators: addition, subtraction, multiplication, division and modulus. Op. Use Description + x + y adds x and y x y
More informationThe Arithmetic Operators
The Arithmetic Operators The arithmetic operators refer to the standard mathematical operators: addition, subtraction, multiplication, division and modulus. Examples: Op. Use Description + x + y adds x
More informationData 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 informationFORM 5 COMPUTING TIME: 1h 45min
DIRECTORATE FOR QUALITY AND STANDARDS IN EDUCATION Curriculum Management and elearning Department Educational Assessment Unit Annual Examinations for Secondary Schools 2014 Track 3 FORM 5 COMPUTING TIME:
More informationRead this before starting!
Points missed: Student's Name: Total score: /100 points East Tennessee State University Department of Computer and Information Sciences CSCI 2150 (Tarnoff) Computer Organization TEST 1 for Spring Semester,
More information60-265: Winter ANSWERS Exercise 4 Combinational Circuit Design
60-265: Winter 2010 Computer Architecture I: Digital Design ANSWERS Exercise 4 Combinational Circuit Design Question 1. One-bit Comparator [ 1 mark ] Consider two 1-bit inputs, A and B. If we assume that
More informationData 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 informationArithmetic and Bitwise Operations on Binary Data
Arithmetic and Bitwise Operations on Binary Data CSCI 224 / ECE 317: Computer Architecture Instructor: Prof. Jason Fritts Slides adapted from Bryant & O Hallaron s slides 1 Boolean Algebra Developed by
More informationDiscrete structures - CS Fall 2017 Questions for chapter 2.1 and 2.2
Discrete structures - CS1802 - Fall 2017 Questions for chapter 2.1 and 2.2 1. (a) For the following switch diagrams, write the corresponding truth table and decide whether they correspond to one of the
More informationCS140 Lecture 03: The Machinery of Computation: Combinational Logic
CS140 Lecture 03: The Machinery of Computation: Combinational Logic John Magee 25 January 2017 Some material copyright Jones and Bartlett Some slides credit Aaron Stevens 1 Overview/Questions What did
More information2. MACHINE REPRESENTATION OF TYPICAL ARITHMETIC DATA FORMATS (NATURAL AND INTEGER NUMBERS).
2. MACHINE REPRESENTATION OF TYPICAL ARITHMETIC DATA FORMATS (NATURAL AND INTEGER NUMBERS). 2.. Natural Binary Code (NBC). The positional code with base 2 (B=2), introduced in Exercise, is used to encode
More informationCS2630: Computer Organization Homework 3 Combinational logic and Logisim Due October 14, 2016, 11:59pm
CS2630: Computer Organization Homework 3 Combinational logic and Logisim Due October 14, 2016, 11:59pm Instructions: You must submit your files to Assignments > Homework 3 on ICON. Make sure your programs
More information[Ch 6] Set Theory. 1. Basic Concepts and Definitions. 400 lecture note #4. 1) Basics
400 lecture note #4 [Ch 6] Set Theory 1. Basic Concepts and Definitions 1) Basics Element: ; A is a set consisting of elements x which is in a/another set S such that P(x) is true. Empty set: notated {
More informationArithmetic and Bitwise Operations on Binary Data
Arithmetic and Bitwise Operations on Binary Data CSCI 2400: Computer Architecture ECE 3217: Computer Architecture and Organization Instructor: David Ferry Slides adapted from Bryant & O Hallaron s slides
More information1. Prove that if you have tri-state buffers and inverters, you can build any combinational logic circuit. [4]
HW 3 Answer Key 1. Prove that if you have tri-state buffers and inverters, you can build any combinational logic circuit. [4] You can build a NAND gate from tri-state buffers and inverters and thus you
More informationIntroduction to Computer Engineering (E114)
Introduction to Computer Engineering (E114) Lab 1: Full Adder Introduction In this lab you will design a simple digital circuit called a full adder. You will then use logic gates to draw a schematic for
More informationBoolean Algebra A B A AND B = A*B A B A OR B = A+B
Boolean Algebra Algebra is the branch of mathematics that deals with variables. Variables represent unknown values and usually can stand for any real number. Because computers use only 2 numbers as we
More informationCS/COE 0447 Example Problems for Exam 2 Spring 2011
CS/COE 0447 Example Problems for Exam 2 Spring 2011 1) Show the steps to multiply the 4-bit numbers 3 and 5 with the fast shift-add multipler. Use the table below. List the multiplicand (M) and product
More informationLecture Notes on Ints
Lecture Notes on Ints 15-122: Principles of Imperative Computation Frank Pfenning Lecture 2 August 26, 2010 1 Introduction Two fundamental types in almost any programming language are booleans and integers.
More informationObjectives: 1- Bolean Algebra. Eng. Ayman Metwali
Objectives: Chapter 3 : 1- Boolean Algebra Boolean Expressions Boolean Identities Simplification of Boolean Expressions Complements Representing Boolean Functions 2- Logic gates 3- Digital Components 4-
More information7/25/2016. Example: Addition of Unsigned Bit Patterns. ECE 120: Introduction to Computing. Adding Two Non-Negative Patterns Can Overflow
University of Illinois at Urbana-Champaign Dept. of Electrical and Computer Engineering ECE 120: Introduction to Computing 2 s Complement Overflow and Boolean Logic Example: ddition of Unsigned Bit Patterns
More informationCS 253. January 14, 2017
CS 253 Department of Computer Science College of Engineering Boise State University January 14, 2017 1/30 Motivation Most programming tasks can be implemented using abstractions (e.g. representing data
More informationSummary of Course Coverage
CS-227, Discrete Structures I Spring 2006 Semester Summary of Course Coverage 1) Propositional Calculus a) Negation (logical NOT) b) Conjunction (logical AND) c) Disjunction (logical inclusive-or) d) Inequalities
More informationOOP- 4 Templates & Memory Management Print Only Pages 1-5 Individual Assignment Answers To Questions 10 Points - Program 15 Points
OOP-4-Templates-Memory-Management-HW.docx CSCI 2320 Initials P a g e 1 If this lab is an Individual assignment, you must do all coded programs on your own. You may ask others for help on the language syntax,
More informationENCM 369 Winter 2019 Lab 6 for the Week of February 25
page of ENCM 369 Winter 29 Lab 6 for the Week of February 25 Steve Norman Department of Electrical & Computer Engineering University of Calgary February 29 Lab instructions and other documents for ENCM
More informationfalse, import, new 1 class Lecture2 { 2 3 "Data types, Variables, and Operators" 4
1 class Lecture2 { 2 3 "Data types, Variables, and Operators" 4 5 } 6 7 // Keywords: 8 byte, short, int, long, char, float, double, boolean, true, false, import, new Zheng-Liang Lu Java Programming 44
More informationCOMPUTER SCIENCE Paper 1
COMPUTER SCIENCE Paper 1 (THEORY) (Three hours) Maximum Marks: 70 (Candidates are allowed additional 15 minutes for only reading the paper. They must NOT start writing during this time) -----------------------------------------------------------------------------------------------------------------------
More informationCOMPUTER SCIENCE PAPER 1
COMPUTER SCIENCE PAPER 1 (THEORY) (Maximum Marks: 70) (Time allowed: Three hours) (Candidates are allowed additional 15 minutes for only reading the paper. They must NOT start writing during this time.)
More informationCO Computer Architecture and Programming Languages CAPL. Lecture 9
CO20-320241 Computer Architecture and Programming Languages CAPL Lecture 9 Dr. Kinga Lipskoch Fall 2017 A Four-bit Number Circle CAPL Fall 2017 2 / 38 Functional Parts of an ALU CAPL Fall 2017 3 / 38 Addition
More informationAP Computer Science Unit 1. Writing Programs Using BlueJ
AP Computer Science Unit 1. Writing Programs Using BlueJ 1. Open up BlueJ. Click on the Project menu and select New Project. You should see the window on the right. Navigate to wherever you plan to save
More informationDIGITAL ARITHMETIC: OPERATIONS AND CIRCUITS
C H A P T E R 6 DIGITAL ARITHMETIC: OPERATIONS AND CIRCUITS OUTLINE 6- Binary Addition 6-2 Representing Signed Numbers 6-3 Addition in the 2 s- Complement System 6-4 Subtraction in the 2 s- Complement
More informationComputer Science 1 Ah
UNIVERSITY OF EDINBURGH course CS0077 FACULTY OF SCIENCE AND ENGINEERING DIVISION OF INFORMATICS SCHOOL OF COMPUTER SCIENCE Computer Science 1 Ah Degree Examination Date: Saturday 25th May 2002 Time: 09:30
More informationBitwise Data Manipulation. Bitwise operations More on integers
Bitwise Data Manipulation Bitwise operations More on integers bitwise operators ex Bitwise operators on fixed-width bit vectors. AND & OR XOR ^ NOT ~ 01101001 & 01010101 01000001 01101001 01010101 01101001
More informationSECONDARY SCHOOL, L-IMRIEĦEL HALF YEARLY EXAMINATIONS 2016/2017
SECONDARY SCHOOL, L-IMRIEĦEL HALF YEARLY EXAMINATIONS 2016/2017 YEAR: 10 Computing Time: 1½ Hr. Name: Class: Instructions: 1. Answer all the questions in the space provided on this paper. 2. Calculators
More informationfalse, import, new 1 class Lecture2 { 2 3 "Data types, Variables, and Operators" 4
1 class Lecture2 { 2 3 "Data types, Variables, and Operators" 4 5 } 6 7 // Keywords: 8 byte, short, int, long, char, float, double, boolean, true, false, import, new Zheng-Liang Lu Java Programming 45
More informationCSC 2400: Computer Systems. Bit- Level vs. Logical Opera<ons. Bit- Level Operators. Common to C and Java &,, ~, ^, <<, >>
CSC 2400: Computer Systems Bit- Level vs. Logical Opera
More information4 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 informationExpressions and Data Types CSC 121 Spring 2015 Howard Rosenthal
Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types
More informationUW CSE 351, Winter 2013 Final Exam
Full Name: Student ID #: UW CSE 351, Winter 2013 Final Exam March 20, 2013 2:30pm - 4:20pm Instructions: Write your full name and UW student ID number on the front of the exam. When the exam begins, make
More informationIB Computer Science Topic.2-
Topic.2- Computer Organization Designed by: Allan Lawson Sources: Online Materials, thanks for all Topic 2.1.1 Computer Architecture Outline the architecture of a central processing unit (CPU) and the
More informationChapter 2: Universal Building Blocks. CS105: Great Insights in Computer Science
Chapter 2: Universal Building Blocks CS105: Great Insights in Computer Science Homework 1 It is now available on our website. Answer questions in Word or any text editor and upload it via sakai. No paper
More informationHomework 1. Due Date: Wednesday 11/26/07 - at the beginning of the lecture
Homework 1 Due Date: Wednesday 11/26/07 - at the beginning of the lecture Problems marked with a [*] are a littlebit harder and count as extra credit. Note 1. For any of the given problems make sure that
More informationAssoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.
Assoc. Prof. Dr. Marenglen Biba (C) 2010 Pearson Education, Inc. All for repetition statement do while repetition statement switch multiple-selection statement break statement continue statement Logical
More information4 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 information11/22/1999 7pm - 9pm. Name: Login Name: Preceptor Name: Precept Number:
Login Preceptor Precept Number: Computer Science 126 Second Midterm Exam 11/22/1999 7pm - 9pm This exam has 10 questions. The weight of each question is printed in the table below and next to each question.
More informationR10. II B. Tech I Semester, Supplementary Examinations, May
SET - 1 1. a) Convert the following decimal numbers into an equivalent binary numbers. i) 53.625 ii) 4097.188 iii) 167 iv) 0.4475 b) Add the following numbers using 2 s complement method. i) -48 and +31
More informationPropositional Calculus: Boolean Algebra and Simplification. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson
Propositional Calculus: Boolean Algebra and Simplification CS 270: Mathematical Foundations of Computer Science Jeremy Johnson Propositional Calculus Topics Motivation: Simplifying Conditional Expressions
More informationComputer Organization
Register Transfer Logic Department of Computer Science Missouri University of Science & Technology hurson@mst.edu 1 Note, this unit will be covered in three lectures. In case you finish it earlier, then
More informationCSE 11 Midterm Fall 2008
Signature cs11f Name Student ID CSE 11 Midterm Fall 2008 Page 1 (10 points) Page 2 (22 points) Page 3 (23 points) Page 4 (17 points) Page 5 (12 points) Total (84 points = 80 base points + 4 points EC [5%])
More informationCARLETON UNIVERSITY. Laboratory 2.0
CARLETON UNIVERSITY Department of Electronics ELEC 267 Switching Circuits Jan 3, 28 Overview Laboratory 2. A 3-Bit Binary Sign-Extended Adder/Subtracter A binary adder sums two binary numbers for example
More informationESC101 : Fundamental of Computing
ESC101 : Fundamental of Computing End Semester Exam 19 November 2008 Name : Roll No. : Section : Note : Read the instructions carefully 1. You will lose 3 marks if you forget to write your name, roll number,
More information(Refer Slide Time 6:48)
Digital Circuits and Systems Prof. S. Srinivasan Department of Electrical Engineering Indian Institute of Technology Madras Lecture - 8 Karnaugh Map Minimization using Maxterms We have been taking about
More informationComputer Science II (20082) Week 1: Review and Inheritance
Computer Science II 4003-232-08 (20082) Week 1: Review and Inheritance Richard Zanibbi Rochester Institute of Technology Review of CS-I Syntax and Semantics of Formal (e.g. Programming) Languages Syntax
More informationhttps://asd-pa.perfplusk12.com/admin/admin_curric_maps_display.aspx?m=5507&c=618&mo=18917&t=191&sy=2012&bl...
Page 1 of 13 Units: - All - Teacher: ProgIIIJavaI, CORE Course: ProgIIIJavaI Year: 2012-13 Intro to Java How is data stored by a computer system? What does a compiler do? What are the advantages of using
More informationChapter 1. 1 Computer-Aided Logic Design. 1.1 Introduction. 1.2 General Philosophy of Problem Specification and Solution
1 Computer-Aided Logic Design 1.1 Introduction Hardware components of computers are physical models of logical reasoning. Procedures based on ligical disciplines of mathematics are used to design these
More information