Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

byte[] to float  RSS feed

 
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
Sheriff
Posts: 23275
125
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
Boost this thread!