Re: binary conversion
Niall Gallagher <[email protected]>
| Newsgroups | gmane.comp.java.sun.servlet |
|---|---|
| Message-ID | <[email protected]> |
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