>>If you still don't understand why my algorithm will work, do a google
search
>>on "twos complement". Trust me...
I understood your algorithm and it will work fine if they have followed
the 2nd approach, which is more likely because of its similarity to
represent 8bit negative values.
>>1000011 does not equal -3, it equals -61.
Yes, for an 8bit signed value. But i was just trying to say that the
implementor might have also used a different representation(since its a
7bit number) in which you take the Highest bit for sign & use only the
rest of bits (6 in our case) for value.
thus 1000011 evaluates to negative 3.
But I am going ahead with your algorithm, since the representation is
similar to 8bit negative values
Thanks & Regards
Praveen
"Ryan Ackley" <[EMAIL PROTECTED]>
31/07/2003 05:13
Please respond to "POI Developers List"
To: "POI Developers List" <[EMAIL PROTECTED]>
cc:
Subject: Re: HWPF queries
> 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/