You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by tn...@apache.org on 2003/01/30 20:14:44 UTC
cvs commit: xml-xerces/c/src/xercesc/util XMLDouble.cpp XMLFloat.cpp
tng 2003/01/30 11:14:44
Modified: c/src/xercesc/util XMLDouble.cpp XMLFloat.cpp
Log:
On some platforms like Solaris strtod will return -0.0. So need to consider this scenario as well.
Revision Changes Path
1.6 +29 -10 xml-xerces/c/src/xercesc/util/XMLDouble.cpp
Index: XMLDouble.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLDouble.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- XMLDouble.cpp 11 Dec 2002 00:20:02 -0000 1.5
+++ XMLDouble.cpp 30 Jan 2003 19:14:43 -0000 1.6
@@ -57,6 +57,9 @@
/*
* $Id$
* $Log$
+ * Revision 1.6 2003/01/30 19:14:43 tng
+ * On some platforms like Solaris strtod will return -0.0. So need to consider this scenario as well.
+ *
* Revision 1.5 2002/12/11 00:20:02 peiyongz
* Doing businesss in value space. Converting out-of-bound value into special values.
*
@@ -151,17 +154,17 @@
void XMLDouble::checkBoundary(const XMLCh* const strValue)
{
- char *nptr = XMLString::transcode(strValue);
+ char *nptr = XMLString::transcode(strValue);
ArrayJanitor<char> jan1(nptr);
int strLen = strlen(nptr);
char *endptr = 0;
- errno = 0;
+ errno = 0;
fValue = strtod(nptr, &endptr);
- // check if all chars are valid char
- if ( (endptr - nptr) != strLen)
+ // check if all chars are valid char
+ if ( (endptr - nptr) != strLen)
{
- ThrowXML(NumberFormatException, XMLExcepts::XMLNUM_Inv_chars);
+ ThrowXML(NumberFormatException, XMLExcepts::XMLNUM_Inv_chars);
}
// check if overflow/underflow occurs
@@ -169,13 +172,29 @@
{
if ( fValue < 0 )
{
- fType = NegINF;
+ if (fValue > (-1)*DBL_MIN)
+ {
+ fType = NegZero;
+ fValue = 0;
+ }
+ else
+ {
+ fType = NegINF;
+ }
}
else if ( fValue > 0)
{
- fType = PosINF;
- }
- else
+ if (fValue < DBL_MIN )
+ {
+ fType = PosZero;
+ fValue = 0;
+ }
+ else
+ {
+ fType = PosINF;
+ }
+ }
+ else
{
fType = (getSign() == 1) ? PosZero : NegZero;
}
1.7 +30 -11 xml-xerces/c/src/xercesc/util/XMLFloat.cpp
Index: XMLFloat.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLFloat.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- XMLFloat.cpp 11 Dec 2002 19:55:16 -0000 1.6
+++ XMLFloat.cpp 30 Jan 2003 19:14:43 -0000 1.7
@@ -57,6 +57,9 @@
/*
* $Id$
* $Log$
+ * Revision 1.7 2003/01/30 19:14:43 tng
+ * On some platforms like Solaris strtod will return -0.0. So need to consider this scenario as well.
+ *
* Revision 1.6 2002/12/11 19:55:16 peiyongz
* set negZero/posZero for float.
*
@@ -146,17 +149,17 @@
void XMLFloat::checkBoundary(const XMLCh* const strValue)
{
- char *nptr = XMLString::transcode(strValue);
+ char *nptr = XMLString::transcode(strValue);
ArrayJanitor<char> jan1(nptr);
int strLen = strlen(nptr);
char *endptr = 0;
- errno = 0;
+ errno = 0;
fValue = strtod(nptr, &endptr);
- // check if all chars are valid char
- if ( (endptr - nptr) != strLen)
+ // check if all chars are valid char
+ if ( (endptr - nptr) != strLen)
{
- ThrowXML(NumberFormatException, XMLExcepts::XMLNUM_Inv_chars);
+ ThrowXML(NumberFormatException, XMLExcepts::XMLNUM_Inv_chars);
}
// check if overflow/underflow occurs
@@ -164,13 +167,29 @@
{
if ( fValue < 0 )
{
- fType = NegINF;
+ if (fValue > (-1)*DBL_MIN)
+ {
+ fType = NegZero;
+ fValue = 0;
+ }
+ else
+ {
+ fType = NegINF;
+ }
}
else if ( fValue > 0)
{
- fType = PosINF;
- }
- else
+ if (fValue < DBL_MIN )
+ {
+ fType = PosZero;
+ fValue = 0;
+ }
+ else
+ {
+ fType = PosINF;
+ }
+ }
+ else
{
fType = (getSign() == 1) ? PosZero : NegZero;
}
@@ -188,7 +207,7 @@
{
fType = NegZero;
fValue = 0;
- }
+ }
else if (fValue > 0 && fValue < FLT_MIN )
{
fType = PosZero;
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org