Re: Dynamically resizing a buffer
Joe Wright <joewwright@com cast.netwrote:
Try it again in ones' complement instead of two's complement:
11111100 a signed char with value -3
Shifting it left will yield
11111000 a signed char with value -7
That certainly doesn't match any definition of multiplication by two
that I'm familiar with.
-Larry Jones
I wonder if you can refuse to inherit the world. -- Calvin
Joe Wright <joewwright@com cast.netwrote:
>
Shifting left (mult) seems to be well defined for both signed and
unsigned integers. It is shifting right (div) which is proplematic for
negative signed integers. The question is whether the implementation
copies the sign bit into the msb of the signed value.
>
Consider:
11111100 a signed char with value -4
Shifting it left with yield
11111000 a signed char with value -8
Shifting left (mult) seems to be well defined for both signed and
unsigned integers. It is shifting right (div) which is proplematic for
negative signed integers. The question is whether the implementation
copies the sign bit into the msb of the signed value.
>
Consider:
11111100 a signed char with value -4
Shifting it left with yield
11111000 a signed char with value -8
11111100 a signed char with value -3
Shifting it left will yield
11111000 a signed char with value -7
That certainly doesn't match any definition of multiplication by two
that I'm familiar with.
-Larry Jones
I wonder if you can refuse to inherit the world. -- Calvin
Comment