Re: error with "if" !!!



On Apr 28, 3:52 am, nakisa <nakisa.noor...@xxxxxxxxx> wrote:
Hi ,everybody
I have encounter with strange error ( strange in my point view !)
In program, I need to find the sample values of function named f . I
use these 3 commands :
1) if (f<0.0005D0 ) then
2) if (abs(f-0.0005D0)<0.001D0) then
3) if (abs(f-0.0005D0)<0.01D0 ) then

to see the answer . I was surprised to see the answer of this commands
are different !
for example , 7.3124E-5 only given by second if !!
my question is what is the best way to find f near a number and why
the above commands give various answers
thanks
nakisa

The answer is inherent in the nature of floating point representation
-- see the following

http://docs.sun.com/source/806-3568/ncg_goldberg.html

.



Relevant Pages

  • error with "if" !!!
    ... I have encounter with strange error ... I was surprised to see the answer of this commands ...
    (comp.lang.fortran)
  • Re: error with "if" !!!
    ... nakisa wrote: ... I have encounter with strange error ... I was surprised to see the answer of this commands ...
    (comp.lang.fortran)
  • Virtual Error
    ... I encounter a very strange error in virtual functions,I write a class A, ... inherited from A,B:pulic A, which has another virtual function, then I write ... Prev by Date: ...
    (microsoft.public.vc.language)
  • [newbie] strange error
    ... I'm currently developing a VB.NET application and I encounter a strange error: ... Private Sub LinkLabel5_LinkClicked(ByVal sender As System.Object, ...
    (microsoft.public.dotnet.general)
  • Re: [SLE] K3b and premature DVD mount
    ... Yes I did encounter the same problem. ... Check the headers for your unsubscription address For additional commands send e-mail to suse-linux-e-help@suse.com Also check the archives at http://lists.suse.com Please read the FAQs: suse-linux-e-faq@suse.com ...
    (SuSE)