From 2b70f5b2a1ca9154273d98fa518db47370c1af65 Mon Sep 17 00:00:00 2001 From: Lu Wang Date: Wed, 30 Jan 2013 04:06:48 +0800 Subject: [PATCH] fix float point number comparison in install_* --- src/HTMLRenderer/install.cc | 8 ++++---- src/util/math.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/HTMLRenderer/install.cc b/src/HTMLRenderer/install.cc index 1ec80ca..a3f7818 100644 --- a/src/HTMLRenderer/install.cc +++ b/src/HTMLRenderer/install.cc @@ -281,7 +281,7 @@ long long HTMLRenderer::install_whitespace(double ws_width, double & actual_widt { // ws_width is already mulitpled by draw_scale auto iter = whitespace_map.lower_bound(ws_width - param->h_eps); - if((iter != whitespace_map.end()) && (abs(iter->first - ws_width) < param->h_eps)) + if((iter != whitespace_map.end()) && (abs(iter->first - ws_width) <= param->h_eps)) { actual_width = iter->first; return iter->second; @@ -297,7 +297,7 @@ long long HTMLRenderer::install_whitespace(double ws_width, double & actual_widt long long HTMLRenderer::install_rise(double rise) { auto iter = rise_map.lower_bound(rise - param->v_eps); - if((iter != rise_map.end()) && (abs(iter->first - rise) < param->v_eps)) + if((iter != rise_map.end()) && (abs(iter->first - rise) <= param->v_eps)) { return iter->second; } @@ -311,7 +311,7 @@ long long HTMLRenderer::install_rise(double rise) long long HTMLRenderer::install_height(double height) { auto iter = height_map.lower_bound(height - EPS); - if((iter != height_map.end()) && (abs(iter->first - height) < EPS)) + if((iter != height_map.end()) && (abs(iter->first - height) <= EPS)) { return iter->second; } @@ -324,7 +324,7 @@ long long HTMLRenderer::install_height(double height) long long HTMLRenderer::install_left(double left) { auto iter = left_map.lower_bound(left - param->h_eps); - if((iter != left_map.end()) && (abs(iter->first - left) < param->h_eps)) + if((iter != left_map.end()) && (abs(iter->first - left) <= param->h_eps)) { return iter->second; } diff --git a/src/util/math.h b/src/util/math.h index 9c9f5db..2966090 100644 --- a/src/util/math.h +++ b/src/util/math.h @@ -15,7 +15,7 @@ namespace pdf2htmlEX { static inline double round(double x) { return (std::abs(x) > EPS) ? x : 0.0; } -static inline bool equal(double x, double y) { return std::abs(x-y) < EPS; } +static inline bool equal(double x, double y) { return std::abs(x-y) <= EPS; } static inline bool is_positive(double x) { return x > EPS; } static inline bool tm_equal(const double * tm1, const double * tm2, int size = 6) {