diff options
-rw-r--r-- | psprint/source/helper/strhelper.cxx | 20 |
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); |