----------------------------------------------------------------
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 Thu, 1 Jun 2000, M. Greenblatt 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...

You are supposing that the Java integers are 16 bit long, and I think they
actually are 32 bit integers, so the & 0xffff operation will put 0s in 
the higher 16 bits. 
I have no idea what it is doing this here, but it certainly *is* having an
effect. 

Cheers,

Arkaitz.



--
--------------------------------------------------------------
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]

Reply via email to