From 2749baf3956934c37bc91f4e46367d83e4964596 Mon Sep 17 00:00:00 2001 From: PeiYong Zhang <peiyongz@apache.org> Date: Thu, 9 Sep 2004 20:09:30 +0000 Subject: [PATCH] getDataOverflowed() git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@176030 13f79535-47bb-0310-9956-ffa450edef68 --- src/xercesc/util/XMLAbstractDoubleFloat.cpp | 4 ++++ src/xercesc/util/XMLAbstractDoubleFloat.hpp | 11 +++++++++++ src/xercesc/util/XMLDouble.cpp | 16 ++++++++-------- src/xercesc/util/XMLFloat.cpp | 18 ++++++++++-------- 4 files changed, 33 insertions(+), 16 deletions(-) diff --git a/src/xercesc/util/XMLAbstractDoubleFloat.cpp b/src/xercesc/util/XMLAbstractDoubleFloat.cpp index c81a5a6b5..44d0bc861 100644 --- a/src/xercesc/util/XMLAbstractDoubleFloat.cpp +++ b/src/xercesc/util/XMLAbstractDoubleFloat.cpp @@ -17,6 +17,9 @@ /* * $Id$ * $Log$ + * Revision 1.29 2004/09/09 20:09:30 peiyongz + * getDataOverflowed() + * * Revision 1.28 2004/09/08 13:56:23 peiyongz * Apache License Version 2.0 * @@ -140,6 +143,7 @@ XMLAbstractDoubleFloat::XMLAbstractDoubleFloat(MemoryManager* const manager) : fValue(0) , fType(Normal) , fDataConverted(false) +, fDataOverflowed(false) , fSign(0) , fRawData(0) , fFormattedString(0) diff --git a/src/xercesc/util/XMLAbstractDoubleFloat.hpp b/src/xercesc/util/XMLAbstractDoubleFloat.hpp index a49169b6b..0db21e7f3 100644 --- a/src/xercesc/util/XMLAbstractDoubleFloat.hpp +++ b/src/xercesc/util/XMLAbstractDoubleFloat.hpp @@ -17,6 +17,9 @@ /* * $Id$ * $Log$ + * Revision 1.24 2004/09/09 20:09:30 peiyongz + * getDataOverflowed() + * * Revision 1.23 2004/09/08 13:56:23 peiyongz * Apache License Version 2.0 * @@ -175,6 +178,8 @@ public: inline bool isDataConverted() const; + inline bool isDataOverflowed() const; + inline double getValue() const; /*** @@ -246,6 +251,7 @@ protected: double fValue; LiteralType fType; bool fDataConverted; + bool fDataOverflowed; private: int fSign; @@ -279,6 +285,11 @@ inline bool XMLAbstractDoubleFloat::isDataConverted() const return fDataConverted; } +inline bool XMLAbstractDoubleFloat::isDataOverflowed() const +{ + return fDataOverflowed; +} + inline double XMLAbstractDoubleFloat::getValue() const { return fValue; diff --git a/src/xercesc/util/XMLDouble.cpp b/src/xercesc/util/XMLDouble.cpp index 8aee7d89c..9207ca804 100644 --- a/src/xercesc/util/XMLDouble.cpp +++ b/src/xercesc/util/XMLDouble.cpp @@ -17,6 +17,9 @@ /* * $Id$ * $Log$ + * Revision 1.15 2004/09/09 20:09:30 peiyongz + * getDataOverflowed() + * * Revision 1.14 2004/09/08 13:56:24 peiyongz * Apache License Version 2.0 * @@ -159,36 +162,33 @@ void XMLDouble::checkBoundary(const XMLCh* const strValue) // check if overflow/underflow occurs if (errno == ERANGE) { + + fDataConverted = true; + if ( fValue < 0 ) { if (fValue > (-1)*DBL_MIN) { - fDataConverted = true; fValue = 0; } else { fType = NegINF; - fDataConverted = true; + fDataOverflowed = true; } } else if ( fValue > 0) { if (fValue < DBL_MIN ) { - fDataConverted = true; fValue = 0; } else { fType = PosINF; - fDataConverted = true; + fDataOverflowed = true; } } - else - { - fDataConverted = true; - } } diff --git a/src/xercesc/util/XMLFloat.cpp b/src/xercesc/util/XMLFloat.cpp index d73859d54..588bbb860 100644 --- a/src/xercesc/util/XMLFloat.cpp +++ b/src/xercesc/util/XMLFloat.cpp @@ -17,6 +17,9 @@ /* * $Id$ * $Log$ + * Revision 1.16 2004/09/09 20:09:30 peiyongz + * getDataOverflowed() + * * Revision 1.15 2004/09/08 13:56:24 peiyongz * Apache License Version 2.0 * @@ -154,36 +157,33 @@ void XMLFloat::checkBoundary(const XMLCh* const strValue) // check if overflow/underflow occurs if (errno == ERANGE) { + + fDataConverted = true; + if ( fValue < 0 ) { if (fValue > (-1)*DBL_MIN) { - fDataConverted = true; fValue = 0; } else { fType = NegINF; - fDataConverted = true; + fDataOverflowed = true; } } else if ( fValue > 0) { if (fValue < DBL_MIN ) { - fDataConverted = true; fValue = 0; } else { fType = PosINF; - fDataConverted = true; + fDataOverflowed = true; } } - else - { - fDataConverted = true; - } } else { @@ -194,6 +194,7 @@ void XMLFloat::checkBoundary(const XMLCh* const strValue) { fType = NegINF; fDataConverted = true; + fDataOverflowed = true; } else if (fValue > (-1)*FLT_MIN && fValue < 0) { @@ -209,6 +210,7 @@ void XMLFloat::checkBoundary(const XMLCh* const strValue) { fType = PosINF; fDataConverted = true; + fDataOverflowed = true; } } } -- GitLab