Navigation Menu

Skip to content

Commit

Permalink
Use epsilon to compare double
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Oct 27, 2017
1 parent 1bd6a26 commit 7918ecc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/operator.c
Expand Up @@ -22,6 +22,8 @@
#include "grn_normalizer.h"

#include <string.h>
#include <math.h>
#include <float.h>

#ifdef GRN_WITH_ONIGMO
# define GRN_SUPPORT_REGEXP
Expand Down Expand Up @@ -195,7 +197,7 @@ grn_operator_to_exec_func(grn_operator op)
r = (x_ == GRN_UINT64_VALUE(y));\
break;\
case GRN_DB_FLOAT :\
r = ((x_ <= GRN_FLOAT_VALUE(y)) && (x_ >= GRN_FLOAT_VALUE(y)));\
r = (fabs(x_ - GRN_FLOAT_VALUE(y)) < DBL_EPSILON);\
break;\
case GRN_DB_SHORT_TEXT :\
case GRN_DB_TEXT :\
Expand Down

0 comments on commit 7918ecc

Please sign in to comment.