summaryrefslogtreecommitdiff
path: root/psprint/source
diff options
context:
space:
mode:
authorPhilipp Lohmann <pl@openoffice.org>2001-12-12 13:39:50 +0000
committerPhilipp Lohmann <pl@openoffice.org>2001-12-12 13:39:50 +0000
commit34379e026e5f581e9287f1fd2719e5c0eb6c26d6 (patch)
tree0db28fd97beb75ac744564ee999c39ab82f6a8fe /psprint/source
parentd1d4754db600f6c2e056f5b68df9653201c94efd (diff)
#95833# rounding issues
Diffstat (limited to 'psprint/source')
-rw-r--r--psprint/source/helper/strhelper.cxx20
1 files changed, 18 insertions, 2 deletions
diff --git a/psprint/source/helper/strhelper.cxx b/psprint/source/helper/strhelper.cxx
index 9f28cb33b055..131b0ce3e316 100644
--- a/psprint/source/helper/strhelper.cxx
+++ b/psprint/source/helper/strhelper.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: strhelper.cxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: pl $ $Date: 2001-05-08 11:46:02 $
+ * last change: $Author: pl $ $Date: 2001-12-12 14:39:50 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -673,6 +673,14 @@ int getValueOfDouble( char* pBuffer, double f, int nPrecision )
int nInt = f;
f -= nInt;
+ // f should really not be 1.0 after this, but some
+ // hardware implementations seem to round at this point
+ // this should take care of *.9999999999...
+ if( f == 1.0 || log10( 1.0 - f ) <= -nPrecision )
+ {
+ nInt++;
+ f = 0.0;
+ }
char pReverseBuffer[12];
int nRev = 0;
@@ -692,6 +700,14 @@ int getValueOfDouble( char* pBuffer, double f, int nPrecision )
f *= 10;
nInt = f;
f -= nInt;
+ // f should really not be 1.0 after this, but some
+ // hardware implementations seem to round at this point
+ // this should take care of *.*9999999...
+ if( f == 1.0 || log10( 1.0 - f ) <= -nPrecision )
+ {
+ nInt++;
+ f = 0.0;
+ }
*pBuffer++ = nInt + '0';
nPrecision--;
} while( f && nPrecision != 0);