What is Floting point error?

Write here if you have problems with your C source code

Moderator: Board moderators

Post Reply
ranacse05
New poster
Posts: 37
Joined: Wed Mar 28, 2007 5:08 pm
Location: Rajshahi
Contact:

What is Floting point error?

Post by ranacse05 » Mon Apr 23, 2007 10:10 pm

plz check this code

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

What is it? And how can i overcome this problem?
Last edited by ranacse05 on Tue Apr 24, 2007 7:07 pm, edited 1 time in total.
I like to solve problems.

stubbscroll
Experienced poster
Posts: 151
Joined: Tue Nov 16, 2004 7:23 pm
Location: Norway
Contact:

Post by stubbscroll » 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.

ranacse05
New poster
Posts: 37
Joined: Wed Mar 28, 2007 5:08 pm
Location: Rajshahi
Contact:

Post by ranacse05 » 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?
I like to solve problems.

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan » 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

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

ranacse05
New poster
Posts: 37
Joined: Wed Mar 28, 2007 5:08 pm
Location: Rajshahi
Contact:

Replay

Post by ranacse05 » Tue Apr 24, 2007 6:51 pm

Thanks jan bhai again,os this is the floting point error,
I like to solve problems.

techyboy
New poster
Posts: 1
Joined: Wed Nov 18, 2015 2:10 pm

Re: What is Floting point error?

Post by techyboy » Wed Nov 18, 2015 2:18 pm

Can you please paste the source code or example code? if your problem is not solved yet.

Post Reply

Return to “C”