Quasi 0
- From: David RF <davranfor@xxxxxxxxx>
- Date: Mon, 4 Jun 2012 02:32:06 -0700 (PDT)
Hi friends:
Machine epsilon is the maximum relative error of the chosen rounding
procedure
#include <stdio.h>
#include <math.h>
#include <float.h>
int main(void)
{
double a = 0.1;
double b = 0.1;
a += 1.0;
a -= 1.0;
printf("a == b = %s\n", a == b ? "equals" : "unequals");
printf("a == b = %s\n", fabs(a - b) < DBL_EPSILON ? "equals" :
"unequals");
return 0;
}
Is this a good method for test the equality?
.
- Follow-Ups:
- Re: Quasi 0
- From: James Kuyper
- Re: Quasi 0
- From: Eric Sosman
- Re: Quasi 0
- From: Noob
- Re: Quasi 0
- Prev by Date: Re: GOTOs discovered in "real world" program! (was Re: Error returns and repeated code, GOTOs, etc.)
- Next by Date: Re: Array sizes and const
- Previous by thread: Array sizes and const
- Next by thread: Re: Quasi 0
- Index(es):