From f75e7f044da48772b5afff8dbfc3378d9a975ac2 Mon Sep 17 00:00:00 2001 From: PeiYong Zhang <peiyongz@apache.org> Date: Mon, 10 Mar 2003 20:55:58 +0000 Subject: [PATCH] Schema Errata E2-40 double/float git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@174845 13f79535-47bb-0310-9956-ffa450edef68 --- src/xercesc/util/XMLAbstractDoubleFloat.cpp | 58 ++++++++++----------- src/xercesc/util/XMLAbstractDoubleFloat.hpp | 5 +- src/xercesc/util/XMLDateTime.hpp | 12 ++--- src/xercesc/util/XMLDouble.cpp | 6 +-- src/xercesc/util/XMLFloat.cpp | 8 ++- src/xercesc/util/XMLNumber.hpp | 11 ++++ 6 files changed, 52 insertions(+), 48 deletions(-) diff --git a/src/xercesc/util/XMLAbstractDoubleFloat.cpp b/src/xercesc/util/XMLAbstractDoubleFloat.cpp index 9f7f57222..c7571cf42 100644 --- a/src/xercesc/util/XMLAbstractDoubleFloat.cpp +++ b/src/xercesc/util/XMLAbstractDoubleFloat.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.10 2003/03/10 20:55:58 peiyongz + * Schema Errata E2-40 double/float + * * Revision 1.9 2003/02/02 23:54:43 peiyongz * getFormattedString() added to return original and converted value. * @@ -148,16 +151,6 @@ void XMLAbstractDoubleFloat::init(const XMLCh* const strValue) fType = NegINF; fSign = -1; } - else if (XMLString::equals(tmpStrValue, XMLUni::fgNegZeroString) ) - { - fType = NegZero; - fSign = -1; - } - else if (XMLString::equals(tmpStrValue, XMLUni::fgPosZeroString) ) - { - fType = PosZero; - fSign = 1; - } else if (XMLString::equals(tmpStrValue, XMLUni::fgPosINFString) ) { fType = PosINF; @@ -228,12 +221,6 @@ void XMLAbstractDoubleFloat::formatString() case NegINF: XMLString::catString(fFormattedString, XMLUni::fgNegINFString); break; - case NegZero: - XMLString::catString(fFormattedString, XMLUni::fgNegZeroString); - break; - case PosZero: - XMLString::catString(fFormattedString, XMLUni::fgPosZeroString); - break; case PosINF: XMLString::catString(fFormattedString, XMLUni::fgPosINFString); break; @@ -265,23 +252,41 @@ int XMLAbstractDoubleFloat::compareValues(const XMLAbstractDoubleFloat* const lV (!rValue->isSpecialValue()) ) { if (lValue->fValue == rValue->fValue) - return 0; + return EQUAL; else - return (lValue->fValue > rValue->fValue) ? 1: -1; + return (lValue->fValue > rValue->fValue) ? GREATER_THAN : LESS_THAN; } // // case#2: lValue special // rValue special // + // Schema Errata E2-40 + // + // Positive Infinity is greater than all other non-NAN value. + // Nan equals itself but is not comparable with (neither greater than nor less than) + // any other value in the value space + // Negative Infinity is less than all other non-NAN values. + // else if ((lValue->isSpecialValue()) && (rValue->isSpecialValue()) ) { if (lValue->fType == rValue->fType) - return 0; + return EQUAL; else - return (lValue->fType > rValue->fType) ? 1 : -1; + { + if ((lValue->fType == NaN) || + (rValue->fType == NaN) ) + { + return INDETERMINATE; + } + else + { + return (lValue->fType > rValue->fType) ? GREATER_THAN : LESS_THAN; + } + } + } // // case#3: lValue special @@ -311,17 +316,12 @@ int XMLAbstractDoubleFloat::compareSpecial(const XMLAbstractDoubleFloat* const s switch (specialValue->fType) { case NegINF: - return -1; - - case NegZero: - case PosZero: - return (normalValue->getSign() > 0 ? -1 : 1); - + return LESS_THAN; case PosINF: - return 1; - + return GREATER_THAN; case NaN: - return 1; + // NaN is not comparable to any other value + return INDETERMINATE; default: XMLString::binToText(specialValue->fType, value1, 16, 10); diff --git a/src/xercesc/util/XMLAbstractDoubleFloat.hpp b/src/xercesc/util/XMLAbstractDoubleFloat.hpp index 152c6d77d..19c9d3a0b 100644 --- a/src/xercesc/util/XMLAbstractDoubleFloat.hpp +++ b/src/xercesc/util/XMLAbstractDoubleFloat.hpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.9 2003/03/10 20:55:58 peiyongz + * Schema Errata E2-40 double/float + * * Revision 1.8 2003/02/02 23:54:43 peiyongz * getFormattedString() added to return original and converted value. * @@ -140,8 +143,6 @@ public: enum LiteralType { NegINF, - NegZero, - PosZero, PosINF, NaN, SpecialTypeNum, diff --git a/src/xercesc/util/XMLDateTime.hpp b/src/xercesc/util/XMLDateTime.hpp index cdbaf76ec..8a4a61a07 100644 --- a/src/xercesc/util/XMLDateTime.hpp +++ b/src/xercesc/util/XMLDateTime.hpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.5 2003/03/10 20:55:58 peiyongz + * Schema Errata E2-40 double/float + * * Revision 1.4 2003/02/02 23:54:43 peiyongz * getFormattedString() added to return original and converted value. * @@ -98,15 +101,6 @@ class XMLUTIL_EXPORT XMLDateTime : public XMLNumber { public: - // to be moved to XMLNumber - enum - { - LESS_THAN = -1, - EQUAL = 0, - GREATER_THAN = 1, - INDETERMINATE = 2 - }; - enum valueIndex { CentYear = 0, diff --git a/src/xercesc/util/XMLDouble.cpp b/src/xercesc/util/XMLDouble.cpp index 3db671062..954f9e756 100644 --- a/src/xercesc/util/XMLDouble.cpp +++ b/src/xercesc/util/XMLDouble.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.8 2003/03/10 20:55:58 peiyongz + * Schema Errata E2-40 double/float + * * Revision 1.7 2003/02/02 23:54:43 peiyongz * getFormattedString() added to return original and converted value. * @@ -177,7 +180,6 @@ void XMLDouble::checkBoundary(const XMLCh* const strValue) { if (fValue > (-1)*DBL_MIN) { - fType = NegZero; fDataConverted = true; fValue = 0; } @@ -191,7 +193,6 @@ void XMLDouble::checkBoundary(const XMLCh* const strValue) { if (fValue < DBL_MIN ) { - fType = PosZero; fDataConverted = true; fValue = 0; } @@ -203,7 +204,6 @@ void XMLDouble::checkBoundary(const XMLCh* const strValue) } else { - fType = (getSign() == 1) ? PosZero : NegZero; fDataConverted = true; } diff --git a/src/xercesc/util/XMLFloat.cpp b/src/xercesc/util/XMLFloat.cpp index 7046660bd..6d167db92 100644 --- a/src/xercesc/util/XMLFloat.cpp +++ b/src/xercesc/util/XMLFloat.cpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.9 2003/03/10 20:55:58 peiyongz + * Schema Errata E2-40 double/float + * * Revision 1.8 2003/02/02 23:54:43 peiyongz * getFormattedString() added to return original and converted value. * @@ -172,7 +175,6 @@ void XMLFloat::checkBoundary(const XMLCh* const strValue) { if (fValue > (-1)*DBL_MIN) { - fType = NegZero; fDataConverted = true; fValue = 0; } @@ -186,7 +188,6 @@ void XMLFloat::checkBoundary(const XMLCh* const strValue) { if (fValue < DBL_MIN ) { - fType = PosZero; fDataConverted = true; fValue = 0; } @@ -198,7 +199,6 @@ void XMLFloat::checkBoundary(const XMLCh* const strValue) } else { - fType = (getSign() == 1) ? PosZero : NegZero; fDataConverted = true; } } @@ -214,13 +214,11 @@ void XMLFloat::checkBoundary(const XMLCh* const strValue) } else if (fValue > (-1)*FLT_MIN && fValue < 0) { - fType = NegZero; fDataConverted = true; fValue = 0; } else if (fValue > 0 && fValue < FLT_MIN ) { - fType = PosZero; fDataConverted = true; fValue = 0; } diff --git a/src/xercesc/util/XMLNumber.hpp b/src/xercesc/util/XMLNumber.hpp index f36dd9e6a..0319c70d7 100644 --- a/src/xercesc/util/XMLNumber.hpp +++ b/src/xercesc/util/XMLNumber.hpp @@ -57,6 +57,9 @@ /* * $Id$ * $Log$ + * Revision 1.5 2003/03/10 20:55:58 peiyongz + * Schema Errata E2-40 double/float + * * Revision 1.4 2003/02/02 23:54:43 peiyongz * getFormattedString() added to return original and converted value. * @@ -88,6 +91,14 @@ class XMLUTIL_EXPORT XMLNumber { public: + enum + { + LESS_THAN = -1, + EQUAL = 0, + GREATER_THAN = 1, + INDETERMINATE = 2 + }; + virtual ~XMLNumber(); /** -- GitLab