Rename bigEndianToUnsignedInt to unsignedBigEndianToDouble.
diff --git a/ndn-cpp/c/encoding/BinaryXMLDecoder.c b/ndn-cpp/c/encoding/BinaryXMLDecoder.c
index 2e65a85..b687357 100644
--- a/ndn-cpp/c/encoding/BinaryXMLDecoder.c
+++ b/ndn-cpp/c/encoding/BinaryXMLDecoder.c
@@ -247,13 +247,13 @@
return 0;
}
-unsigned int ndn_BinaryXMLDecoder_bigEndianToUnsignedInt(unsigned char *bytes, unsigned int bytesLength)
+double ndn_BinaryXMLDecoder_unsignedBigEndianToDouble(unsigned char *bytes, unsigned int bytesLength)
{
- unsigned int result = 0;
+ double result = 0.0;
unsigned int i;
for (i = 0; i < bytesLength; ++i) {
- result <<= 8;
- result += (unsigned int)bytes[i];
+ result *= 256.0;
+ result += (double)bytes[i];
}
return result;
diff --git a/ndn-cpp/c/encoding/BinaryXMLDecoder.h b/ndn-cpp/c/encoding/BinaryXMLDecoder.h
index 2686e81..d157ca7 100644
--- a/ndn-cpp/c/encoding/BinaryXMLDecoder.h
+++ b/ndn-cpp/c/encoding/BinaryXMLDecoder.h
@@ -132,12 +132,13 @@
(struct ndn_BinaryXMLDecoder *self, unsigned int expectedTag, int *value);
/**
- * Convert the big endian bytes to an unsigned int. Don't check for overflow.
+ * Interpret the bytes as an unsigned big endian integer and convert to a double. Don't check for overflow.
+ * We use a double because it is large enough to represent NDN time (4096 ticks per second since 1970).
* @param bytes pointer to the array of bytes
* @param bytesLength the length of bytes
- * @return the result unsigned int
+ * @return the result
*/
-unsigned int ndn_BinaryXMLDecoder_bigEndianToUnsignedInt(unsigned char *bytes, unsigned int bytesLength);
+double ndn_BinaryXMLDecoder_unsignedBigEndianToDouble(unsigned char *bytes, unsigned int bytesLength);
/**
* Set the offset into the input, used for the next read.
diff --git a/ndn-cpp/c/encoding/BinaryXMLInterest.c b/ndn-cpp/c/encoding/BinaryXMLInterest.c
index 1dda876..2ba6e66 100644
--- a/ndn-cpp/c/encoding/BinaryXMLInterest.c
+++ b/ndn-cpp/c/encoding/BinaryXMLInterest.c
@@ -226,7 +226,7 @@
return error;
interest->interestLifetimeMilliseconds = 1000.0 *
- (double)ndn_BinaryXMLDecoder_bigEndianToUnsignedInt(interestLifetime, interestLifetimeLength) / 4096.0;
+ ndn_BinaryXMLDecoder_unsignedBigEndianToDouble(interestLifetime, interestLifetimeLength) / 4096.0;
}
else
interest->interestLifetimeMilliseconds = -1.0;