I have forgotten
my Password

Or login with:

  • Facebookhttp://facebook.com/
  • Googlehttps://www.google.com/accounts/o8/id
  • Yahoohttps://me.yahoo.com
Index » Programming » C/C++ »

lucian\′s Photo
18 Nov 06, 11:02PM
In fact a better alternative to this would be using an epsilon constant to check whether the value of the product slope1*slope2 is "close enough" to -1, considering roundoff errors. Thus instead of just writing

I suggest you write the following

#include <math.h>
 
// epsilon constant
#define EPS 1E-6
 
...
 
if (fabs(slope1*slope2 + 1.0) < EPS) cout << "lines are perpendicular";
Currently you need to be logged in to leave a message.