Re: binary conversion

K D <[email protected]>
Newsgroups gmane.comp.java.sun.servlet
Message-ID <[email protected]>
thank you very much Niall
it works,

Ken


--- Niall Gallagher <[email protected]> wrote:
> Hi
>
> Whoops! Sorry about that, it should have been AND
> with 0xff
> and not 0x00, it was early!!
>
> byte num[4] = // whatever
>
> int bigE =   ((num[0] & 0xff)
>        | ((num[1] & 0xff) << 8)
>        | ((num[2] & 0xff) << 16)
>        | ((num[3] & 0xff) << 24));
>
>
> Or this, whatever big endian is ... try em both
>
> int bigE =  ((num[3] & 0xff)
>        | ((num[2] & 0xff) << 8)
>        | ((num[1] & 0xff) << 16)
>        | ((num[0] & 0xff) << 24));
>
>
> This definetly works for 8-bit binary data
> represented as an array of 4 for a 32-bit int.
>
> Niall
>
>
___________________________________________________________________________
> To unsubscribe, send email to [email protected]
> and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives:
>
http://archives.java.sun.com/archives/servlet-interest.html
> Resources:
>
http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help:
> http://www.lsoft.com/manuals/user/user.html
>


__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com

___________________________________________________________________________
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.