@paule32: We are talking about Multi_Int_XV type here, not simple integers.

11111111111111111111111111111111 <- this is Integer(-1)

00000000000000000000000000000001 <- this is Abs(Integer(-1))

So should I call Abs() before doing bitwise operations? I guess not.

If I want to change the sign, I can do it like this:

int := int xor (1 shl 31)

If the type is not Integer but Multi_Int_XV, I cant do this because "you cant do bitwise operations on negative values". Of course if I first call Abs() on the value, it will work, but the value will be completely wrong.

@ad1mt: Again, you can know the real decimal value of the "bits" only if you know how to treat the bits, as signed or not. Currently you store a boolean flag to tell if this value is "negative" or not. Instead, you should store if its SIGNED or not. Bitwise operations operate on bits, the decimal value doesnt matter, if negative, above 100, equal to 33 or whatever.

I didnt read all the code in your 15k LOC unit, I dont know how it actually works. The "decimal value" when returned as String should be built knowing if the expected value is signed or unsigned, not if its negative or not.

Also I dont know why changing 1 bit (the most significant bit in 32bit value) causes "overflow" exception when converting it back to 4 byte Integer.

var

i: integer;

m: Multi_Int_XV;

begin

i := 1;

m := i; // 4 bytes

m := m xor (1 shl 31); // still 4 bytes

i := m; // overflow exception, but its still 4 bytes

If I touch the "sign bit", its overflow.