Computer Science: An Overview (13th Edition) (What's New in Computer Science)
13th Edition
ISBN: 9780134875460
Author: Glenn Brookshear, Dennis Brylow
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 2, Problem 36CRP
a.
Program Plan Intro
- Initialize the variable “bit_pattern1” as “00000000”.
- Initialize the variable “bit_pattern2” as “11110000” which is the mask value.
- Perform logical “OR” operation between the value of the variables “bit_pattern1” and “bit_pattern2” to display “1’s” in upper 4-bits, store the resultant value in the variable “result”.
- Print the result.
b.
Program Plan Intro
Program plan:
- Initialize the variable “bit_pattern1” as “00000000”.
- Initialize the variable “bit_pattern2” as “10000000” which is the mask value.
- Perform logical “XOR” operation between the value of the variables “bit_pattern1” and “bit_pattern2” to find complement of most significant bit in pattern, store the resultant value in the variable “result”.
- Print the result.
c.
Program Plan Intro
Program plan:
- Initialize the variable “bit_pattern1” as “00000000”.
- Initialize the variable “bit_pattern2” as “11111111” which is the mask value.
- Perform logical “XOR” operation between the value of the variables “bit_pattern1” and “bit_pattern2” to find complement of 8-bits pattern, store the resultant value in the variable “result”.
- Print the result.
d.
Program Plan Intro
Program plan:
- Initialize the variable “bit_pattern1” as “00000000”.
- Initialize the variable “bit_pattern2” as “01111111” which is the mask value.
- Perform logical “AND” operation between the value of the variables “bit_pattern1” and “bit_pattern2” to find “0” in least significant bit, store the resultant value in the variable “result”.
- Print the result.
e.
Program Plan Intro
Program plan:
- Initialize the variable “bit_pattern1” as “00000000”.
- Initialize the variable “bit_pattern2” as “01111111” which is the mask value.
- Perform logical “OR” operation between the value of the variables “bit_pattern1” and “bit_pattern2” to find “1” in all bits except the most significant bit, store the resultant value in the variable “result”.
- Print the result.
f.
Program Plan Intro
Program plan:
- Initialize the variable “bit_pattern1” as “111111111111111111111111”.
- Initialize the variable “bit_pattern2” as “111111111111111111111111” which is the mask value.
- Perform logical “XOR” operation between the value of the variables “bit_pattern1” and “bit_pattern2” to find change the color to black, store the resultant value in the variable “result1”.
- Initialize anremaining variable “bit_pattern3” as “111111110000000011111111” which is the mask value to filter all the green components.
- Perform logical “OR” operation between the value of the variables “result1” and “bit_pattern3” to filter out all green color components, store the resultant value in the variable “result2”.
- Print the result.
g.
Program Plan Intro
Program plan:
- Initialize the variable “bit_pattern1” as “111111111111111111111111”.
- Initialize the variable “bit_pattern2” as “111111111111111111111111” which is the mask value.
- Perform logical “XOR” operation between the value of the variables “bit_pattern1” and “bit_pattern2” to invert all bits, store the resultant value in the variable “result”.
- Print the result.
h.
Program Plan Intro
Program plan:
- Initialize the variable “bit_pattern1” as “111111111111111111111111”.
- Initialize the variable “bit_pattern2” as “000000000000000000000000” which is the mask value.
- Perform logical “XOR” operation between the value of the variables “bit_pattern1” and “bit_pattern2” to invert all bits, store the resultant value in the variable “result”.
- Print the result.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
15. Consider the following Java-like code:
int number = <<read number from user>>;
int mask = MASK;
int result = number OP mask;
if (result != 0) {
print("Bit 8 was set");
}
The above code is supposed to print “Bit 8 was set” if bit 8 of user’s number was set to 1. If bit 8 was not set, then this code should not print anything (result==0). What hexadecimal value should MASK be, and what bit-wise operation should OP be, for the above code to work correctly?
You are given two bit locations, i and j, together with the 32-bit values N and M. To insert M into N, provide a procedure that starts M at bit j and finishes it at bit i. It is safe to presume that all of M can fit in the bits j through i. In other words, you may infer that there are at least 5 bits between j and i if M = 10011. M could not completely fit between bit 3 and bit 2, thus you would not, for instance, have j = 3 and i = 2.
Suppose you want to isolate the middle 4 bits of a byte by placing 0s in the other 4 bits without disturbing the middle 4 bits. What mask must you use together with what operation?
Suppose you want to complement the 4 middle bits of a byte while leaving the other 4 bits undisturbed. What mask must you use together with what operation?
Chapter 2 Solutions
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Ch. 2.1 - What sequence of events do you think would be...Ch. 2.1 - What information must the CPU supply to the main...Ch. 2.1 - Prob. 3QECh. 2.2 - Prob. 1QECh. 2.2 - In the text, JUMP instructions were expressed by...Ch. 2.2 - Is the instruction If 0 equals 0, then jump to...Ch. 2.2 - Write the example program in Figure 2.7 in actual...Ch. 2.2 - The following are instructions written in Vole...Ch. 2.2 - What is the difference between the instructions...Ch. 2.2 - Here are some instructions in English. Translate...
Ch. 2.3 - Prob. 1QECh. 2.3 - Suppose the Vole memory cells at addresses 0xB0 to...Ch. 2.3 - Suppose the Vole memory cells at addresses 0xA4 to...Ch. 2.3 - Suppose the Vole memory cells at addresses 0xF0 to...Ch. 2.4 - Prob. 1QECh. 2.4 - Prob. 2QECh. 2.4 - Prob. 3QECh. 2.4 - a. Suppose you XOR the first 2 bits of a string of...Ch. 2.4 - Prob. 5QECh. 2.4 - Prob. 6QECh. 2.4 - Prob. 7QECh. 2.4 - Prob. 8QECh. 2.4 - Prob. 9QECh. 2.4 - Prob. 10QECh. 2.4 - Using Vole machine language (Appendix C), write a...Ch. 2.4 - Prob. 12QECh. 2.5 - Prob. 1QECh. 2.5 - Prob. 2QECh. 2.5 - Prob. 3QECh. 2.6 - The hypotenuse example script truncates the sides...Ch. 2.6 - Prob. 2QECh. 2.6 - The Python built-in function str () will convert a...Ch. 2.6 - Use the Python built-in bin () to write a script...Ch. 2.6 - Prob. 6QECh. 2.7 - Referring back to Questions 3 of Section 2.3, if...Ch. 2.7 - Prob. 2QECh. 2.7 - Suppose there were two central processing units...Ch. 2 - a. In what way are general-purpose registers and...Ch. 2 - Answer the following questions in Vole machine...Ch. 2 - Prob. 3CRPCh. 2 - What is the value of the program counter in the...Ch. 2 - Prob. 5CRPCh. 2 - Prob. 6CRPCh. 2 - Prob. 7CRPCh. 2 - Suppose a machine language is designed with an...Ch. 2 - Translate the following instructions from English...Ch. 2 - Rewrite the program in Figure 2.7 assuming that...Ch. 2 - Classify each of the following Vole instructions...Ch. 2 - Prob. 12CRPCh. 2 - Prob. 13CRPCh. 2 - Suppose the memory cells at addresses 0x00 through...Ch. 2 - Suppose the memory cells at addresses 0x00 through...Ch. 2 - Suppose the memory cells at addresses 0x00 through...Ch. 2 - Suppose the memory cells at addresses 0x00 through...Ch. 2 - Prob. 18CRPCh. 2 - If the Vole executes an instruction every...Ch. 2 - Prob. 20CRPCh. 2 - Prob. 21CRPCh. 2 - Prob. 22CRPCh. 2 - Prob. 23CRPCh. 2 - Write a program in Vole to compute the sum of...Ch. 2 - Prob. 26CRPCh. 2 - Prob. 27CRPCh. 2 - Suppose the following program, written in Vole, is...Ch. 2 - Summarize the steps involved when the Vole...Ch. 2 - Summarize the steps involved when the Vole...Ch. 2 - Summarize the steps involved when the Vole...Ch. 2 - Suppose the registers 0x4 and 0x5 in the Vole...Ch. 2 - Prob. 33CRPCh. 2 - Prob. 34CRPCh. 2 - Prob. 35CRPCh. 2 - Prob. 36CRPCh. 2 - Prob. 37CRPCh. 2 - Prob. 38CRPCh. 2 - Prob. 39CRPCh. 2 - Prob. 40CRPCh. 2 - Prob. 41CRPCh. 2 - Prob. 42CRPCh. 2 - a. What single instruction in the Vole machine...Ch. 2 - Write a Vole program that reverses the contents of...Ch. 2 - Write a Vole program that subtracts the value...Ch. 2 - Prob. 46CRPCh. 2 - Suppose a person is typing forty words per minute...Ch. 2 - Prob. 48CRPCh. 2 - Suppose the Vole communicates with a printer using...Ch. 2 - Write a Vole program that places 0s in all the...Ch. 2 - Prob. 51CRPCh. 2 - Prob. 52CRPCh. 2 - Suppose you are given 32 processors, each capable...Ch. 2 - Prob. 54CRPCh. 2 - Prob. 55CRPCh. 2 - Describe how the average of a collection of...Ch. 2 - Write and test a Python script that reads in a...Ch. 2 - Write and test a Python script that reads in a...Ch. 2 - Prob. 59CRPCh. 2 - Suppose a computer manufacturer develops a new...Ch. 2 - Prob. 2SICh. 2 - Prob. 3SICh. 2 - Prob. 4SICh. 2 - Suppose a manufacturer produces a computer chip...Ch. 2 - Prob. 6SICh. 2 - Prob. 7SICh. 2 - Prob. 8SI
Knowledge Booster
Similar questions
- You are provided the 32-bit values N and M together with the two bit positions i and j. Provide a technique that begins M at bit j and ends it at bit i in order to insert M into N. It is fair to assume that bits j through i can accommodate all of M. In other words, if M = 10011, you may assume that there are at least 5 bits between j and i. You would not, for example, have j = 3 and i = 2 since M could not totally fit between bit 3 and bit 2.arrow_forwardSuppose we are working with an error-correcting code that will allow all single-bit errors to be corrected for memory words of length 12. a) How long should the check bits and why? b) Code words are created according to the Hamming Algorithm presented in the text. We now receive the following code word: 0 1 1 0 0 1 0 1 0 0 1 1 0 1 0 0 1 Assuming even parity, is this a legal code word? If not, according to our error-correcting code, where is the error? PLEASE SHOW ALL WORKING UNDERSTANDABLE THANK YOUarrow_forwardSuppose we are working with an error-correcting code that will allow all single-bit errors to be corrected for memory words of length 12. a) How long should the check bits and why? b) Code words are created according to the Hamming Algorithm presented in the text. We now receive the following code word: 0 1 1 0 0 1 0 1 0 0 1 1 0 1 0 0 1 Assuming even parity, is this a legal code word? If not, according to our error-correcting code, where is the error?arrow_forward
- Assume that D has the value 1010101010 and that the 5-bit generator G=10011 is used. What does R stand for? B. C. Does corruption exist? Publish your work. Repetition of parts a and b with the addition of the following: the numbers 1001010101, 0101101010, and 1010100000arrow_forwardTake into consideration the binary BCH code, which is 127 bits long and has a distance of 6 bits intended for it, and use the binary field extension F 128, which is 128 bits in size. How big is the code, and can you guarantee a certain minimum distance between entries?arrow_forwardThe Hewlett-Packard 2114, 2115, and 2116 used a format with the left most 16 bits being the fraction stored in two’s complement format, followed by another 16-bit field which had the left most 8 bits as an extension of the fraction (making the fraction 24 bits long), and the rightmost 8 bits representing the exponent. However, in an interesting twist, the exponent was stored in signmagnitude format with the sign bit on the far right! Write down the bit pattern to represent 1.5625 101 assuming this format. No hidden 1 is used. Comment on how the range and accuracy of this 32-bit pattern compares to the single precision IEEE 754 standard.arrow_forward
- You have 10 temperature sensors, each which can express a temperature from -60 to +120 C. Only integer values are needed. Come up with the least number of bits to encode this data. How much memory in bytes does it take for all the sensors to store 100 samples each? What if the temperature range was to change to -120 to +150 C - how many bits to encode the data now? If you are constrained to store the binary values in whole bytes, how many bytes does it take to store one temperature value? How many bytes are now required to store 100 samples from each of the 10 sensors?arrow_forward// Task 3 // For this function, you must return the largest power of 2 that // is less than or equal to x (which will be positive). You may // not use multiplication or some sort of power function to do this, // and should instead rely on bitwise operations and the underlying // binary representation of x. If x is 0, then you should return 0. unsigned largest_po2_le(unsigned x) { return x; }arrow_forwardOne way of detecting errors is to transmit data as a block of n rows of k bits per row and adding parity bits to each row and each column. The lower-right corner is a parity bit that checks its row and its column, Will this scheme detect all single errors? Double errors? Triple errors?arrow_forward
- Assume that the following block of 16 bits is to be sent using a checksum of 8 bits. What is the pattern (codeword) sent? The block 0f 16 bits is 10101001 00111001.arrow_forwardIn the Hamming coding system (7.3), its representation is expressed as 3 control (test) bits and 7 total bits (data+control bits).In the literature, control bits are represented as (cl, c2, c3, or (pl, p2, p3, .) The bit string sent by encoding with Hamming coding (15,4) is on the receiving side, It is retrieved as 001100101100 (pl.p2.dll). According to this bit sequence;Which option is given according to the control bits (p1.p2.p3.p4) sequence of the received bit sequence?A 0110B 1100C 1001D 0011E 0010arrow_forwardSuppose we are working with an error-correcting code that will allow all single-bit errors to be corrected for memory words of length 7. We have already calculated that we need 4 check bits, and the length of all code words will be 11. Code words are created according to the Hamming algorithm presented in the text. We now receive the following code word: 1 0 1 0 1 0 1 0 1 1 0 Assuming odd parity, is this a legal code word? If not, according to our error-correcting code, where is the error?arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education