blob: f537047562f68c6a714878859a4ee9ded583a4a0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
#include <math.h>
#include "epsilon.h"
/* Numerical errors sometimes make a floating point number just slightly
larger or smaller than its true value. When it matters, we need to
compare with some tolerance, REAL_EPSILON, defined in kbase.h. */
bool
epsilon_equal(float const v1,
float const v2) {
return
v1 == v2 /* Usually they'll be exactly equal, anyway. */
|| fabs(v1 - v2) <= REAL_EPSILON;
}
|