Question: 5. (5 marks) Write code for a function with the following prototype: /Addition that saturates to TMin or TMax / int saturating_add(int x, int y);

5. (5 marks) Write code for a function with the following prototype: /Addition that saturates to TMin or TMax / int saturating_add(int x, int y); Instead of overflowing the way normal twos-complement addition does, satu- rating addition returns INT_MAX when there would be positive overflow, and INT_MIN when there would be negative overflow. Saturating arithmetic is com monly used in programs that perform digital signal processing. Your function should follow the bit-level integer coding rules above. Submit your solutions via urcourses in a single zipfile. Place the solution to the 5 questions in subfolders named q1, q2, etc. Your source files should be named similarly: q1.cpp, q1.h, q2.cpp, q2.h, etc. Notice that each solution will have a corresponding * .h file. Your functions must follow the specification strictly or you won't get marks for your work. I'll expect to be able to include your *.h file and run my test code successfully Your code should be written in standard C or C++, (that is, without using any compiler-specific extensions) and should compile unchanged under g++ 4.8+ or clang 3.7+
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
