Re: [xml] XPath mod operator problems
- From: Bjorn Reese <breese mail1 stofanet dk>
- To: xml gnome org
- Subject: Re: [xml] XPath mod operator problems
- Date: Sat, 29 Jun 2002 10:08:19 +0000
Geert Kloosterman wrote:
There's one other thing. Isn't the real problem the comparison of the
floats? Comparing floats is a tricky thing.
Indeed. Because of the inexact representation of floating-point number
we must use an inexact comparison like this
A - epsilon < B < A + epsilon
where A and B are the floating-point numbers we want to compare, and
epsilon is the (positive) tolerance.
In C, using a macro as syntactical sugar, this translates into (caveat:
untested code)
#define DBL_EQUAL(a,b) ((((a) - DBL_EPSILON) < (b)) && ((b) < ((a) +
DBL_EPSILON)))
if (DBL_EQUAL(A, B))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]