Re: comparing doubles for equality
- From: Tim Prince <timothyprince@xxxxxxxxxxxxx>
- Date: Sat, 30 Dec 2006 23:30:40 GMT
John Smith wrote:
This code for the comparison of fp types is taken from the C FAQ.Depending on how you use this, you could make your application highly dependent on external issues, such as whether you compile for an extra precision mode, or disable gradual underflow.
Any problems using it in a macro?
/* compare 2 doubles for equality */
#define DBL_ISEQUAL(a,b) (fabs((a)-(b))<=(DBL_EPSILON)*fabs((a)))
Do the same issues involved in comparing 2 fp types for equality
apply to comparing a float to zero? E.g. is if(x == 0.0) considered harmful?
.
- Follow-Ups:
- Re: comparing doubles for equality
- From: CBFalconer
- Re: comparing doubles for equality
- References:
- comparing doubles for equality
- From: John Smith
- comparing doubles for equality
- Prev by Date: Good ways to analyze a running c-program?
- Next by Date: Re: c / c++ : is it end of era ?
- Previous by thread: comparing doubles for equality
- Next by thread: Re: comparing doubles for equality
- Index(es):
Relevant Pages
|