Page 1 of 1
What is Floting point error?
Posted: Mon Apr 23, 2007 10:10 pm
plz check this code
What is it? And how can i overcome this problem?
Posted: Tue Apr 24, 2007 1:44 am
If I spotted correctly, you are dividing by zero. You set d5=fabs(x1-x3), which is 0, and two lines later you divide by 2.0*d5.
Posted: Tue Apr 24, 2007 10:17 am
thanks for your help,but if it is 0 then what should i do?should i use 0.0?
Posted: Tue Apr 24, 2007 2:24 pm
Suppose x=0. So, for floating points you can assume that x is so close to zero. Now let eps = .00000001.
Code: Select all
// replace it with
if( fabs(x) <eps ) // fabs(x) returns absolute value of x
Posted: Tue Apr 24, 2007 6:51 pm
Thanks jan bhai again,os this is the floting point error,
Re: What is Floting point error?
Posted: Wed Nov 18, 2015 2:18 pm
Can you please paste the source code or example code? if your problem is not solved yet.