Hi, this is my first post (so please go easy^^), I've been given an assignment to produce a sine wave simulator in terminal. I'm using the GNU g++ compiler.
My problem is comparing two doubles and outputting the higher value, I've included a small program to demonstrate my problem. In the program I would like to output the numbers above 1.75. Also if there is a better way of comparing doubles I would appreciate any ideas:
Thank you in advance 
My problem is comparing two doubles and outputting the higher value, I've included a small program to demonstrate my problem. In the program I would like to output the numbers above 1.75. Also if there is a better way of comparing doubles I would appreciate any ideas:
Rich (BB code):
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double numbers = 0.25; // double number to work with
int count = 0;
cout << "Show numbers 1.75 and over:" << endl;
cout << "___________________________" << endl;
for (count; count < 10; count++) // count to ten
{
numbers = numbers + 0.25; // double + 0.25 for my values
if (fabs(numbers < 1.75) < 0.01) ; // if float absolute number over 1.75 then
{
cout << (numbers); // output the numbers.
cout << (" = ") << (fabs(numbers < 1.75)<0.01) << endl;
}
}
return 0;
}