Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

byte[] to float

 
Chiranjeevi Kanthraj
Ranch Hand
Posts: 290
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
i have the byte[](size is 4) which have HEX values
i want to convert it in to float.

thanks in advance.
 
Henry Wong
author
Marshal
Pie
Posts: 20893
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic