----------------------------------------------------------------
BEFORE YOU POST, search the faq at <http://java.apache.org/faq/>
WHEN YOU POST, include all relevant version numbers, log files,
and configuration files. Don't make us guess your problem!!!
----------------------------------------------------------------
>on 6/1/2000 1:21 AM, M. Greenblatt at [EMAIL PROTECTED] wrote:
>
>> In the readWord() method of class Ajpv12InputStream.java we have the
>> following bitwise operation:
>>
>> return ((int)((b1 << 8) | b2)) & 0xffff;
>>
>> Does anyone happen to know the utility of the '& 0xffff' in this? From
>> what I can see it has no effect whatsoever on the final result.
>>
>> Let me give an example for those of us who dont enjoy bit logic.
>>
>> Assume:
>> b1 = 0000000010101010
>> b2 = 0000000011001100
>>
>> (b1 << 8) = 1010101000000000 | b2
>> = 1010101011001100 & 0xffff
>> = 1010101011001100
>>
>> Just wondering if I'm missing something here...
>>
>> Thanks,
>> MG
>
>I failed this course in college. :-) I need some more help here...
>
>So, should I remove it? Does it hurt to leave it in there?
>
>-jon
It certainly does not hurt.
It seems to me to be just a bit of defensive programming
to ensure that the result is _absolutely_ not greater than
a 16-bit value. This would be true anyway, *assuming* that
b1 and b2 are never more than 8-bit values.
Call it redundant/unnecessary, call it defensive/safe.
It certainly doesn't do anything bad.
Stephen
--
--------------------------------------------------------------
Please read the FAQ! <http://java.apache.org/faq/>
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Archives and Other: <http://java.apache.org/main/mail.html>
Problems?: [EMAIL PROTECTED]