OT: Wacky Way To Read A Byte[] - someone help explain?

Hans Fugal hans at fugal.net
Fri May 19 15:00:00 MDT 2006


On Fri, 19 May 2006 at 14:52 -0600, Levi Pearson wrote:
> >
> >So, if the array has 0xC0 as the first byte, and 0x1C as the second  
> >byte, this should return the integer 49180.
> >
> >Right?
> 
> No, you'll notice that it is also reversing the byte order.  If the  
> byte at i is 0xC0 and i+1 is 0x1C, the int will be 0x1CC0, or 7360.   

Right, what he said. :)

That other guy may have a point with casting in Java. In C it's not
necessary.

-- 
Hans Fugal ; http://hans.fugal.net
 
There's nothing remarkable about it. All one has to do is hit the 
right keys at the right time and the instrument plays itself.
    -- Johann Sebastian Bach


More information about the PLUG mailing list