You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by am...@apache.org on 2009/08/13 14:16:44 UTC

svn commit: r803857 - /xerces/c/trunk/src/xercesc/util/XMLFloat.cpp

Author: amassari
Date: Thu Aug 13 12:16:44 2009
New Revision: 803857

URL: http://svn.apache.org/viewvc?rev=803857&view=rev
Log:
Instead of using the FLT_MIN and FLT_MAX macros, use the XMLSchema definition of minimum and maximum value for a xs:float

Modified:
    xerces/c/trunk/src/xercesc/util/XMLFloat.cpp

Modified: xerces/c/trunk/src/xercesc/util/XMLFloat.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/XMLFloat.cpp?rev=803857&r1=803856&r2=803857&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/XMLFloat.cpp (original)
+++ xerces/c/trunk/src/xercesc/util/XMLFloat.cpp Thu Aug 13 12:16:44 2009
@@ -23,14 +23,7 @@
 //  Includes
 // ---------------------------------------------------------------------------
 #include <xercesc/util/XMLFloat.hpp>
-#include <xercesc/util/XMLString.hpp>
-#include <xercesc/util/NumberFormatException.hpp>
-#include <xercesc/util/Janitor.hpp>
-
-#include <string.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <float.h>
+#include <math.h>
 
 XERCES_CPP_NAMESPACE_BEGIN
 
@@ -57,23 +50,29 @@
         /**
          *  float related checking
          */
-        if (fValue < (-1) * FLT_MAX)
+
+        // 3.2.4 The basic value space of float consists of the values m × 2^e, where 
+        //    m is an integer whose absolute value is less than 2^24, 
+        //    and e is an integer between -149 and 104, inclusive
+        static const double fltMin = pow(2.0,-149);
+        static const double fltMax = pow(2.0,24) * pow(2.0,104);
+        if (fValue < (-1) * fltMax)
         {
             fType = NegINF;
             fDataConverted = true;
             fDataOverflowed = true;
         }
-        else if (fValue > (-1)*FLT_MIN && fValue < 0)
+        else if (fValue > (-1)*fltMin && fValue < 0)
         {
             fDataConverted = true;
             fValue = 0;
         }
-        else if (fValue > 0 && fValue < FLT_MIN )
+        else if (fValue > 0 && fValue < fltMin )
         {
             fDataConverted = true;
             fValue = 0;
         }
-        else if  (fValue > FLT_MAX)
+        else if  (fValue > fltMax)
         {
             fType = PosINF;
             fDataConverted = true;



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org