This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes byte[] to float Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "byte[] to float" Watch "byte[] to float" New topic
Author

byte[] to float

Chiranjeevi Kanthraj
Ranch Hand

Joined: Feb 18, 2008
Posts: 288

Hi all
i have the byte[](size is 4) which have HEX values
i want to convert it in to float.

thanks in advance.


-Chiru
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18113
    
  39

Well, that depends on what does "convert" mean. What needs to be changed to "convert" the byte array to a float value?

Now, if by "convert", the byte array is already holding the bits for the float, and you just need those bits for the float. You can do this...



BTW, the ByteBuffer class is in the java.nio package.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: byte[] to float
 
Similar Threads
float
int i = (byte)3.2f ...i is 3 how come?
int to float conversion !
charAt Assignments
Cast Object to Object[]