diff --git a/include/hrleGrid.hpp b/include/hrleGrid.hpp index 6f3de0e..7bf2c77 100644 --- a/include/hrleGrid.hpp +++ b/include/hrleGrid.hpp @@ -54,14 +54,14 @@ template class hrleGrid { // strictly monotonic decreasing static char getBitSizeOfNumber(long number) { - const bool isNegative = number < 0; number = std::abs(number); char bitSize = 0; while (number != 0) { number >>= 1; ++bitSize; } - return isNegative ? bitSize + 1 : bitSize; + // one additional bit for the sign + return bitSize + 1; } static char getByteSizeOfNumber(long number) { @@ -640,7 +640,7 @@ template class hrleGrid { } } gridBoundaryBytes = - std::min(gridBoundaryBytes, char(8)); // maximum of 8 Bytes + std::min(gridBoundaryBytes, char(sizeof(hrleIndexType))); // grid properties stream.write(reinterpret_cast(&gridBoundaryBytes), sizeof(char));