diff -u gdal-1.8.1-orig/gcore//gdalpamrasterband.cpp gdal-1.8.1/gcore//gdalpamrasterband.cpp --- gdal-1.8.1-orig/gcore//gdalpamrasterband.cpp 2011-07-09 13:33:34.000000000 -0300 +++ gdal-1.8.1/gcore//gdalpamrasterband.cpp 2011-08-02 13:37:42.000000000 -0300 @@ -33,6 +33,11 @@ #include "gdal_rat.h" #include "cpl_string.h" +#include +#ifndef DBL_IS_EQUAL +#define DBL_IS_EQUAL(a, b) (fabs((a)-(b)) < FLT_EPSILON) +#endif + CPL_CVSID("$Id: gdalpamrasterband.cpp 21714 2011-02-13 18:37:57Z rouault $"); /************************************************************************/ @@ -1007,11 +1012,10 @@ if( psXMLHist->eType != CXT_Element || !EQUAL(psXMLHist->pszValue,"HistItem") ) continue; - - // should try and make min/max test a bit fuzzy. - - if( atof(CPLGetXMLValue( psXMLHist, "HistMin", "0")) != dfMin - || atof(CPLGetXMLValue( psXMLHist, "HistMax", "0")) != dfMax + + // fix to make min/max test a bit fuzzy, using DBL_IS_EQUAL + if( ! DBL_IS_EQUAL( atof(CPLGetXMLValue( psXMLHist, "HistMin", "0")), dfMin) + || ! DBL_IS_EQUAL( atof(CPLGetXMLValue( psXMLHist, "HistMax", "0")), dfMax) || atoi(CPLGetXMLValue( psXMLHist, "BucketCount","0")) != nBuckets || !atoi(CPLGetXMLValue( psXMLHist,