Question: / / This program demonstrates how to safely test a floating - point number / / to see if it is , for all practical
This program demonstrates how to safely test a floatingpoint number
to see if it is for all practical purposes, equal to some value.
#include
#include
using namespace std;
int main
double result ;
of should be and, if you print result, is displayed.
cout "result result endl;
However, internally result is NOT precisely equal to
So test to see if it is "close" to
if result
cout "result DOES equal endl;
else
cout "result DOES NOT equal endl;
return ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
