tag 577031 - wontfix
tag 577031 + patch
notfound 577031 xpdf/3.02-1.4+lenny1
thanks

On Tue, May 18, 2010 at 04:16:57PM +0400, Yuriy M. Kaminskiy wrote:
> Note that zoomA, dpiA, rotateA are floating point. (Exact) comparison of two
> floating point number can give unexpected result due to rounding (especially 
> due
> to internal use of extended precision [long double] in i386 fpu registers).

Yup, that's it.

Basically, dpiA is computed, and then compared with its old value (dpi).
Both should be equal, but since dpiA was computed just before, it is
still "hot" in the FPU and has a slighly more precise value, different
from its double representation.

Testing fabs() instead fixed it for me.  Values are typical DPI values
(e.g. 72 for me), so 0.001 should be more than fine.  I did not bother
with zoom, since it does not fit this problematic pattern.  (There's
already a sh*tload of floating-point comparisons in there, so why bother
with this one.)

(There's no way to use -ffloat-store for only one variable, is there?)


My thanks to you and Michael for solving this mystery.


-- 
Ummm, well, OK.  The network's the network, the computer's the computer.
Sorry for the confusion.
                -- Sun Microsystems
>From c716b9f6853d7ba2ca61fc8aecd6b509d0f06195 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Bri=C3=A8re?= <fbri...@fbriere.net>
Date: Sun, 30 May 2010 08:35:20 -0400
Subject: [PATCH] Prevent floating-point comparison from constantly updating PDF

The computation of dpiA just prior to its comparison with dpi can, on a
x86 FPU, yield a slightly different value from what will be stored back
in the double variable.  The effect of this was PDFCore::update()
constantly re-processing the PDF when scrolling.
---
 xpdf/PDFCore.cc |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/xpdf/PDFCore.cc b/xpdf/PDFCore.cc
index fb3df3f..51fd987 100644
--- a/xpdf/PDFCore.cc
+++ b/xpdf/PDFCore.cc
@@ -443,7 +443,7 @@ void PDFCore::update(int topPageA, int scrollXA, int scrollYA,
   // object
   if (force || pages->getLength() == 0 ||
       (!continuousMode && topPageA != topPage) ||
-      zoomA != zoom || dpiA != dpi || rotateA != rotate) {
+      zoomA != zoom || fabs(dpiA - dpi) >= 0.001 || rotateA != rotate) {
     needUpdate = gTrue;
     setSelection(0, 0, 0, 0, 0);
     while (pages->getLength() > 0) {
-- 
1.7.1

Reply via email to