1
0
mirror of https://github.com/pdf2htmlEX/pdf2htmlEX.git synced 2024-07-05 01:28:39 +00:00

fix float point number comparison in install_*

This commit is contained in:
Lu Wang 2013-01-30 04:06:48 +08:00
parent 71f1cb3b8a
commit 2b70f5b2a1
2 changed files with 5 additions and 5 deletions

View File

@ -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;
}

View File

@ -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)
{