Question: 3 . 5 7 LAB: Comparing floats Instructor note: Remember, floating - point numbers only have limited precision and calci One way to compare equality

3.57 LAB: Comparing floats
Instructor note:
Remember, floating-point numbers only have limited precision and calci One way to compare equality is to take the absolute value (use a math f to "equal" and "epsilon", where EQUAL =0.001 and epsilon is just th The order of input being read is: value 1, value 2, and epsilon (st a final "else" to compare if equal, close enough, or not close.
Write a program that is given two floats for comparison and a third float th phrases:
output "equal" if the floats are within 0.001(exclusively) of each othe
output "close enough" if the floats are within epsilon (exclusively) of
outpulnot close" if floats are not within epsilon
Ex: If the input is:
14.1
14.2
0.2
the output is:
close enough
Ex: If the input is:
2.1125
2.1132
0.02
the output is:
equal
Ex: If the input is:
 3.57 LAB: Comparing floats Instructor note: Remember, floating-point numbers only have

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!