Question: c++ must use func prototype Part D: Delta Compare function Create a function called compareDelta() that takes three parameters all doubles. The first two are

c++ must use func prototype

c++ must use func prototype Part D: Delta Compare function Create a

Part D: Delta Compare function Create a function called compareDelta() that takes three parameters all doubles. The first two are the numbers to compare. The last parameter is the "delta". It returns a true if the absolute value of the difference of the two parameters is between the plus/minus of delta parameter which is your accepted tolerance for equality. The delta parameter is always > 0. The function prototype is: bool compareDelta(const double &, const double &, const double &); The C++ library function fabs() can be used to find the absolute value of a double or float [NOTE - you must #include header file to access fabs()]. Some examples of the intended behavior for your function are: Example 1: Number1: 1.205 Number2: 1.305 Delta: 0.100 This set of numbers would return TRUE. Example 2: EECE1080C/CS1021C Lab Functions 1 Topics covered: CH Program Development, Functions Number1: 1.3058 Number2: 1.3059 Delta: 0.00001 This set of numbers would return FALSE. In engineering and scientific computing, you cannot directly compare the values of floating-point numbers to test equality. This is because there is always some round-off error that is present in the machine representation of the numbers. When comparing floats/doubles you need to use a tolerance! TESTING - Test your code using the specified values for each number and complete the following table (NOTE - this table is for your use only. It need not be submitted for grading): Number 1 Number 2 Delta Value Result from Code 1.205 1.305 0.1 1.3058 1.3059 1.3058 1.3059 0.0001 1.3058 1.3059 0.00001 Table 4 - Delta Test Table ? ? 0.00001

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!