encoding: Ensuring minimal-length encoding for nonNegativeInteger

Change-Id: Iefb758530729f6c520c90dd36eeff2f43401f62e
refs: #1284
diff --git a/src/encoding/encoding-buffer.hpp b/src/encoding/encoding-buffer.hpp
index b46225b..4251fa9 100644
--- a/src/encoding/encoding-buffer.hpp
+++ b/src/encoding/encoding-buffer.hpp
@@ -166,7 +166,7 @@
 {
 public:
   EncodingImpl (size_t totalReserve = 8800,
-                  size_t reserveFromBack = 400)
+                size_t reserveFromBack = 400)
   {
   }
 
@@ -329,7 +329,7 @@
 inline size_t
 EncodingImpl<encoding::Buffer>::prependNonNegativeInteger (uint64_t varNumber)
 {
-  if (varNumber < 253) {
+  if (varNumber <= std::numeric_limits<uint8_t>::max()) {
     return prependByte (static_cast<uint8_t> (varNumber));
   }
   else if (varNumber <= std::numeric_limits<uint16_t>::max ()) {
@@ -349,7 +349,7 @@
 inline size_t
 EncodingImpl<encoding::Estimator>::prependNonNegativeInteger (uint64_t varNumber)
 {
-  if (varNumber < 253) {
+  if (varNumber <= std::numeric_limits<uint8_t>::max()) {
     return 1;
   }
   else if (varNumber <= std::numeric_limits<uint16_t>::max ()) {
@@ -448,7 +448,7 @@
 inline size_t
 EncodingImpl<encoding::Buffer>::appendNonNegativeInteger (uint64_t varNumber)
 {
-  if (varNumber < 253) {
+  if (varNumber <= std::numeric_limits<uint8_t>::max ()) {
     return appendByte (static_cast<uint8_t> (varNumber));
   }
   else if (varNumber <= std::numeric_limits<uint16_t>::max ()) {