CPR workshop4

.docx

School

Seneca College *

*We aren’t endorsed by this school

Course

144

Subject

Computer Science

Date

Feb 20, 2024

Type

docx

Pages

3

Uploaded by CorporalComputerNightingale26

Report
Number Systems Activity Computer Principles for Programmers Abhijeet Singh 144374220 asingh1289 @mySeneca.ca Click or tap here to enter text. There are many notes in the instructions to help you earn marks for the questions below. Exercise One of Two integer overflow (80 points) 1) (7.5 points) ) If a variable counting seconds is stored in a signed long 32-bit integer, how many days will it take until that integer overflows? (to one decimal place) 248.55 days until it over flows 2) (15 points) Convert the maximum value of an unsigned long 32-bit integer, representing hundredths of a second, into whole numbers of days : hours : minutes : seconds . hundredths of a second. After n days, how many hours remain? After n hours, how many minutes remain? etc. 497 2 27 52 95 DAYS   HOURS : MINUTES : SECONDS  . HUNDREDTH S 3) (2.5 points) What are the maximum and minimum values that can be stored in a short 16-bit signed integer? 16-bit signed integer maximum =32767 … minimum = -32768 4) (5+5 points) Give examples of two short 16-bit signed integers that when added together would cause overflow. 16386 + 16386 are two positive values causing overflow when added together. -16500 + -16501 are two negative values causing overflow when added together. Binary Search Bug 5) (10 points) What is potentially wrong with the (low + high) / 2 calculation to find the middle point? Under what conditions would the calculation go wrong?   It may lead to an overflow because high and low can exceed range after adding up and will eventually lead to overflow as it is greater than the maximum value. SUMMER 2023 1 of 3
Number Systems Activity Computer Principles for Programmers 6) (10 points) REWRITE the mid calculation to prevent overflow from mid = (low + high) / 2; to mid = low +(high-low)/2; ; 7) (25 points) Write a 250+ word “reflection”(similar to a workshop in your programming class) describing the steps you used to develop and test your solution to the calculation bug. There are many steps that are used by me when I develop and test the solution to the calculation bug. I have learned that this requires a systematic approach, so I implemented few steps which are given below. The first step is to find out the problem or error and solve the issue. In my solution the bug was the wrong answer generated because of the overflow of the integers during calculating the middle point. I then tried to figure out a way to get rid of the error or the bug by doing several researches. I even took some advice from one of my senior, who told me that the problem was overflow of the integers. To keep the answer within a limited and valid range, I applied the formula, mid = low + (high – low) / 2. After that, I implemented the code by using the correct syntax and variables so that there are no further errors to encounter. The next step after executing the test was to look for any more bug or error, if there was any I rectified them by using debug and double checking my code. Furthermore, I even evaluated its performance and effiency. I recorded the whole developing and testing process. I was able to enhance my knowledge about problem solving. By following these few steps, I developed a correct solution and even tested my solution. This systematic process has always allowed me to learn about the problem solving, developing and testing the solution. Exercise Two of Two Numbering Systems and Conversions (20 points) 8) (10 points ) What is the hex value for these colours? Red decimal Green decimal Blue decimal Hex triplet Colour Description 15 245 231 #0FF5E7 TEAL 192 255 238 #C0FFEE LIGHT GREEN 208 13 30 #D00D1E RED 186 187 30 #BABBE DARK YELLOW 126 164 112 #7EA470 GREEN SUMMER 2023 2 of 3
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help