> The algorithm for signing a 7bit 2's complement value is cool, but i am
> confused as to  select which approach from the 2 given below.
>
> let me consider an example, say byte x = 3;  -> 00000011
> now x = -3 will be                                                      ->
> 11111101   (as per the usual representation of negative values)
>
> Ist approach:
> if we find the 7 bit value as                                    ->
> 0000011
> then check the 7th bit (Hi bit), its 0 so its a  positive 3
>
> if we find the 7 bit value as                                    ->
> 1000011
> then check the 7th bit (Hi bit), its 1 so its a  negative 3

1000011 does not equal -3, it equals -61. A negative twos complement is the
binary inverse of the positive number plus 1. The msb will always be 1 for a
negative number. By looking for the sign bit and simply filling the the 8th
bit with a 1 is the same as filling it with a zero for a positive number.

If you still don't understand why my algorithm will work, do a google search
on "twos complement". Trust me...

Ryan


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List:    http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/

Reply via email to