#include <stdio.h>
#include <math.h>

#define ZBX_DOUBLE_EPSILON	0.000001

#define SUCCEED	0
#define FAIL	-1

static int	zbx_double_compare(double a, double b)
{
	return fabs(a - b) <= ZBX_DOUBLE_EPSILON ? SUCCEED : FAIL;
}

int main(void)
{
	float	d1 = 0.1e-9f;
	float	d2 = 0.5e-9f;
	float	diff = d2 - d1;
	float	rel_diff = (d2 - d1) * 100.0f / d1;

    	printf("%g and %g are %s\n", (double)d1, (double)d2,
			(SUCCEED == zbx_double_compare(d1, d2)) ? "equal" : "not equal");
    	printf("%g - %g = %g\n", (double)d2, (double)d1, (double)diff);
    	printf("relative difference between %g and %g is %g %%\n", (double)d2, (double)d1, (double)rel_diff);
}
