peiyongz 2003/12/11 20:51:29
Modified: c/src/xercesc/util XMLAbstractDoubleFloat.cpp
Log:
trailing zeros for double/float w/o decimal point
Revision Changes Path
1.19 +32 -7 xml-xerces/c/src/xercesc/util/XMLAbstractDoubleFloat.cpp
Index: XMLAbstractDoubleFloat.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/XMLAbstractDoubleFloat.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- XMLAbstractDoubleFloat.cpp 11 Dec 2003 21:38:12 -0000 1.18
+++ XMLAbstractDoubleFloat.cpp 12 Dec 2003 04:51:29 -0000 1.19
@@ -57,6 +57,9 @@
/*
* $Id$
* $Log$
+ * Revision 1.19 2003/12/12 04:51:29 peiyongz
+ * trailing zeros for double/float w/o decimal point
+ *
* Revision 1.18 2003/12/11 21:38:12 peiyongz
* support for Canonical Representation for Datatype
*
@@ -549,19 +552,37 @@
*retPtr++ = manBuf[0];
*retPtr++ = chPeriod;
- if (totalDigits - 1 > 0)
+ //XMLBigDecimal::parseDecimal() will eliminate trailing zeros
+ // iff there is a decimal points
+ // eg. 56.7800e0 -> manBuf = 5678, totalDigits = 4, fractDigits = 2
+ // we print it as 5.678e1
+ //
+ // but it wont remove trailing zeros if there is no decimal point.
+ // eg. 567800e0 -> manBuf = 567800, totalDigits = 6, fractDigits = 0
+ // we print it 5.67800e5
+ //
+ // for the latter, we need to print it as 5.678e5 instead
+ //
+ XMLCh* endPtr = manBuf + totalDigits;
+
+ if (fractDigits == 0)
+ {
+ while(*(endPtr - 1) == chDigit_0)
+ endPtr--;
+ }
+
+ int remainLen = endPtr - &(manBuf[1]);
+
+ if (remainLen)
{
- XMLString::copyNString(retPtr, &(manBuf[1]), totalDigits - 1);
- retPtr += (totalDigits - 1);
+ XMLString::copyNString(retPtr, &(manBuf[1]), remainLen);
+ retPtr += remainLen;
}
else
{
*retPtr++ = chDigit_0;
}
- *retPtr++ = chLatin_E;
- *retPtr = chNull;
-
/***
*
* . adjust expValue
@@ -572,6 +593,10 @@
***/
expValue += (totalDigits - 1) - fractDigits ;
XMLString::binToText(expValue, expStr, strLen, 10);
+ *retPtr++ = chLatin_E;
+ *retPtr = chNull;
+
+
XMLString::catString(&(retBuffer[0]), expStr);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]