diff --git a/core/Integer.cc b/core/Integer.cc index 42e5eb984881eb91b3fdbd5a7a336036ecbd70f9..1301fae04ca553d91451ca17139327ac6cb97db3 100644 --- a/core/Integer.cc +++ b/core/Integer.cc @@ -1177,7 +1177,7 @@ int INTEGER::RAW_encode(const TTCN_Typedescriptor_t& p_td, RAW_enc_tree& myleaf) } else { // not IntX, use the field length length = (p_td.raw->fieldlength + 7) / 8; - if (min_bits(value, neg_sgbit) > p_td.raw->fieldlength) { + if (min_bits(value) > p_td.raw->fieldlength) { TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_LEN_ERR, "There are insufficient bits to encode '%s' : ", p_td.name); value = 0; // substitute with zero diff --git a/core/RAW.cc b/core/RAW.cc index 80d2180840f63e04938ed312cefb86f8e016425e..3a220ae713f33bd64a6f7672b3c1c0d56d0d7cee 100644 --- a/core/RAW.cc +++ b/core/RAW.cc @@ -309,16 +309,13 @@ RAW_enc_tree* RAW_enc_tree::get_node(RAW_enc_tr_pos &req_pos) * @return the number of bits needed to represent the given integer * in sign+magnitude */ -int min_bits(int a, bool signbit) +int min_bits(int a) { - if (a == INT_MIN) { - return sizeof(int) * 8 + signbit; - } register int bits = 0; register int tmp = a; if (a < 0) { bits = 1; - tmp = -a; // doesn't work on INT_MIN + tmp = -a; } while (tmp != 0) { bits++; diff --git a/core/RAW.hh b/core/RAW.hh index 6c32d68f7ce8388591584a5c814ed7ddbee7c6b9..410566776e8bb465ec9c55b9ef1943dccded4061 100644 --- a/core/RAW.hh +++ b/core/RAW.hh @@ -52,7 +52,7 @@ extern const unsigned char BitMaskTable[9]; class RAW_enc_tree; struct TTCN_Typedescriptor_t; struct TTCN_TEXTdescriptor_t; -int min_bits(int a, bool signbit); +int min_bits(int a); int min_bits(BIGNUM *a); enum ext_bit_t{ EXT_BIT_NO, /**< No extension bit */