Re: binary conversion

Niall Gallagher <[email protected]>
Newsgroups gmane.comp.java.sun.servlet
Message-ID <[email protected]>
>does anyone now how to convert binary integer (4 byte)
>into decimal in Big-endian format?


int num = 1234; // 32 bits of an int

int low = 0xffff0000 & num;  // take first 16 bits
int high = 0x0000ffff & num;  // take last 16 bits


int bigE = low ^ high;
int littleE = high ^ low;


I may be confused in regards to big and little endian formats, its been a while....but you get the idea.

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