Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

math functions

Status
Not open for further replies.

kjb

Technical User
Oct 24, 2000
11
0
0
CA
hey guys

i just made a very simple if else program in which if i use cos or sin, or ne trig functin it comes false even tho its true! i'll paste the program below

#include <cmath>
#include <iostream>
#include <stdio.h>
#include <math.h>


using namespace std;

void main ()

{

if (cos(.52)==cos(.52))
cout << &quot; The Statement is true &quot;;
else
cout << &quot; The statement is false&quot;;







return ;
}

can some1 plz inform me of what 2 do ??

thnx
 
You should never compare floating point numbers for equality, since they aren't represented exactly in memory. you should instead compare within some reasonable range.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top