ModuleOneCS405

docx

School

Southern New Hampshire University *

*We aren’t endorsed by this school

Course

405

Subject

Computer Science

Date

Feb 20, 2024

Type

docx

Pages

5

Uploaded by BailiffYakMaster294

Report
For this assignment, we had to modify the two test functions. The first step was of course to read and understand the source code given to me. After that it was time to start trying stuff! At first, I thought I had to modify the add and subtract functions even though there was no TODO there. Obviously that was wrong and after 45 minutes of fumbling stuff around I realized I was in the completely wrong spot. So I took a step back, and carefully read through the TODO instructions. After another little while of trying different things, I kept getting an error that “increment” needed to be included in the function. The key was to modify these test functions to handle the failures correctly. In the test_overflow method, I adjusted the add_numbers function to avoid overflow, and in the test_underflow method, I made changes to the subtract_numbers function to prevent underflow. That’s when it all started to click and I was able to successfully complete the assignment. I will paste the complete raw console log on a separate page below because I wanted to include the code in the screenshot, and the screenshot wouldn’t be big enough for the entire console anyway. Starting Numeric Underflow / Overflow Tests!
************************************************** *** Running Overflow Tests *** ************************************************** Overflow Test of Type = char Adding Numbers Without Overflow (0, 25, 5) = 125 Adding Numbers With Overflow (0, 25, 6) = -106 Overflow Test of Type = wchar_t Adding Numbers Without Overflow (0, 13107, 5) = 65535 Adding Numbers With Overflow (0, 13107, 6) = 13106 Overflow Test of Type = short Adding Numbers Without Overflow (0, 6553, 5) = 32765 Adding Numbers With Overflow (0, 6553, 6) = -26218 Overflow Test of Type = int Adding Numbers Without Overflow (0, 429496729, 5) = 2147483645 Adding Numbers With Overflow (0, 429496729, 6) = -1717986922 Overflow Test of Type = long Adding Numbers Without Overflow (0, 429496729, 5) = 2147483645 Adding Numbers With Overflow (0, 429496729, 6) = -1717986922 Overflow Test of Type = __int64 Adding Numbers Without Overflow (0, 1844674407370955161, 5) = 9223372036854775805 Adding Numbers With Overflow (0, 1844674407370955161, 6) = -7378697629483820650 Overflow Test of Type = unsigned char Adding Numbers Without Overflow (0, 51, 5) = 255 Adding Numbers With Overflow (0, 51, 6) = 50 Overflow Test of Type = unsigned short Adding Numbers Without Overflow (0, 13107, 5) = 65535 Adding Numbers With Overflow (0, 13107, 6) = 13106 Overflow Test of Type = unsigned int Adding Numbers Without Overflow (0, 858993459, 5) = 4294967295 Adding Numbers With Overflow (0, 858993459, 6) = 858993458 Overflow Test of Type = unsigned long Adding Numbers Without Overflow (0, 858993459, 5) = 4294967295 Adding Numbers With Overflow (0, 858993459, 6) = 858993458 Overflow Test of Type = unsigned __int64 Adding Numbers Without Overflow (0, 3689348814741910323, 5) = 18446744073709551615 Adding Numbers With Overflow (0, 3689348814741910323, 6) = 3689348814741910322 Overflow Test of Type = float Adding Numbers Without Overflow (0, 6.80565e+37, 5) = 3.40282e+38
Adding Numbers With Overflow (0, 6.80565e+37, 6) = inf Overflow Test of Type = double Adding Numbers Without Overflow (0, 3.59539e+307, 5) = 1.79769e+308 Adding Numbers With Overflow (0, 3.59539e+307, 6) = inf Overflow Test of Type = long double Adding Numbers Without Overflow (0, 3.59539e+307, 5) = 1.79769e+308 Adding Numbers With Overflow (0, 3.59539e+307, 6) = inf ************************************************** *** Running Undeflow Tests *** ************************************************** Underflow Test of Type = char Subtracting Numbers Without Overflow (127, 25, 5) = 2 Subtracting Numbers With Overflow (127, 25, 6) = -23 Subtracting Numbers Without Overflow (127, 25, 5) = 2 Subtracting Numbers With Overflow (127, 25, 6) = -23 Underflow Test of Type = wchar_t Subtracting Numbers Without Overflow (65535, 13107, 5) = 0 Subtracting Numbers With Overflow (65535, 13107, 6) = 52429 Subtracting Numbers Without Overflow (65535, 13107, 5) = 0 Subtracting Numbers With Overflow (65535, 13107, 6) = 52429 Underflow Test of Type = short Subtracting Numbers Without Overflow (32767, 6553, 5) = 2 Subtracting Numbers With Overflow (32767, 6553, 6) = -6551 Subtracting Numbers Without Overflow (32767, 6553, 5) = 2 Subtracting Numbers With Overflow (32767, 6553, 6) = -6551 Underflow Test of Type = int Subtracting Numbers Without Overflow (2147483647, 429496729, 5) = 2 Subtracting Numbers With Overflow (2147483647, 429496729, 6) = -429496727 Subtracting Numbers Without Overflow (2147483647, 429496729, 5) = 2 Subtracting Numbers With Overflow (2147483647, 429496729, 6) = -429496727 Underflow Test of Type = long Subtracting Numbers Without Overflow (2147483647, 429496729, 5) = 2 Subtracting Numbers With Overflow (2147483647, 429496729, 6) = -429496727 Subtracting Numbers Without Overflow (2147483647, 429496729, 5) = 2 Subtracting Numbers With Overflow (2147483647, 429496729, 6) = -429496727 Underflow Test of Type = __int64 Subtracting Numbers Without Overflow (9223372036854775807, 1844674407370955161, 5) = 2 Subtracting Numbers With Overflow (9223372036854775807, 1844674407370955161, 6) = -1844674407370955159
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
Subtracting Numbers Without Overflow (9223372036854775807, 1844674407370955161, 5) = 2 Subtracting Numbers With Overflow (9223372036854775807, 1844674407370955161, 6) = -1844674407370955159 Underflow Test of Type = unsigned char Subtracting Numbers Without Overflow (255, 51, 5) = 0 Subtracting Numbers With Overflow (255, 51, 6) = 205 Subtracting Numbers Without Overflow (255, 51, 5) = 0 Subtracting Numbers With Overflow (255, 51, 6) = 205 Underflow Test of Type = unsigned short Subtracting Numbers Without Overflow (65535, 13107, 5) = 0 Subtracting Numbers With Overflow (65535, 13107, 6) = 52429 Subtracting Numbers Without Overflow (65535, 13107, 5) = 0 Subtracting Numbers With Overflow (65535, 13107, 6) = 52429 Underflow Test of Type = unsigned int Subtracting Numbers Without Overflow (4294967295, 858993459, 5) = 0 Subtracting Numbers With Overflow (4294967295, 858993459, 6) = 3435973837 Subtracting Numbers Without Overflow (4294967295, 858993459, 5) = 0 Subtracting Numbers With Overflow (4294967295, 858993459, 6) = 3435973837 Underflow Test of Type = unsigned long Subtracting Numbers Without Overflow (4294967295, 858993459, 5) = 0 Subtracting Numbers With Overflow (4294967295, 858993459, 6) = 3435973837 Subtracting Numbers Without Overflow (4294967295, 858993459, 5) = 0 Subtracting Numbers With Overflow (4294967295, 858993459, 6) = 3435973837 Underflow Test of Type = unsigned __int64 Subtracting Numbers Without Overflow (18446744073709551615, 3689348814741910323, 5) = 0 Subtracting Numbers With Overflow (18446744073709551615, 3689348814741910323, 6) = 14757395258967641293 Subtracting Numbers Without Overflow (18446744073709551615, 3689348814741910323, 5) = 0 Subtracting Numbers With Overflow (18446744073709551615, 3689348814741910323, 6) = 14757395258967641293 Underflow Test of Type = float Subtracting Numbers Without Overflow (3.40282e+38, 6.80565e+37, 5) = 0 Subtracting Numbers With Overflow (3.40282e+38, 6.80565e+37, 6) = -6.80565e+37 Subtracting Numbers Without Overflow (3.40282e+38, 6.80565e+37, 5) = 0 Subtracting Numbers With Overflow (3.40282e+38, 6.80565e+37, 6) = -6.80565e+37 Underflow Test of Type = double Subtracting Numbers Without Overflow (1.79769e+308, 3.59539e+307, 5) = 9.9792e+291 Subtracting Numbers With Overflow (1.79769e+308, 3.59539e+307, 6) = -3.59539e+307
Subtracting Numbers Without Overflow (1.79769e+308, 3.59539e+307, 5) = 9.9792e+291 Subtracting Numbers With Overflow (1.79769e+308, 3.59539e+307, 6) = -3.59539e+307 Underflow Test of Type = long double Subtracting Numbers Without Overflow (1.79769e+308, 3.59539e+307, 5) = 9.9792e+291 Subtracting Numbers With Overflow (1.79769e+308, 3.59539e+307, 6) = -3.59539e+307 Subtracting Numbers Without Overflow (1.79769e+308, 3.59539e+307, 5) = 9.9792e+291 Subtracting Numbers With Overflow (1.79769e+308, 3.59539e+307, 6) = -3.59539e+307 All Numeric Underflow / Overflow Tests Complete! C:\Users\Owen\source\repos\ModuleOne\Debug\ModuleOne.exe (process 13112) exited with code 0. To automatically close the console when debugging stops, enable Tools->Options->Debugging- >Automatically close the console when debugging stops. Press any key to close this window . . .