Page 1 of 1

What is Floting point error?

Posted: Mon Apr 23, 2007 10:10 pm
by ranacse05
plz check this code

************code removed***********

What is it? And how can i overcome this problem?

Posted: Tue Apr 24, 2007 1:44 am
by stubbscroll
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
by ranacse05
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
by Jan
Suppose x=0. So, for floating points you can assume that x is so close to zero. Now let eps = .00000001.

Code: Select all

if(x==0)
    do something...
    // replace it with
if( fabs(x) <eps ) // fabs(x) returns absolute value of x
    do something...

Replay

Posted: Tue Apr 24, 2007 6:51 pm
by ranacse05
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
by techyboy
Can you please paste the source code or example code? if your problem is not solved yet.