-
How to convert a byte data stream to float, double ...
Hi, all,
I input a binay data stream created by different platform. The data stream
has a sequence of different data type such 4 byte integer, 4 byte float ...
in its original binary format. I need to retrieve the data, and also deal
with different byte order problem.
I read the data into a byte[] first, then try to manupulate it, and reinterprete
it . I could read the value use DataInoutStream.readFloat() etc. to retrieve
the value directly, if I do not have the byte order problem. Therefore I
have to swab the byte order, before I can interpret the data.
With integer type of data, I can swab byte using shift operator (>>, <<).
But I do not know how to do byte swab to a float or double in Java.
In c or c++, it is quite easy to manupulate the bit and byte in memory, and
reinterpret it in whatever the way you want.
How can I do this in Java?
Thanks
Jianxin
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks