The Artima Developer Community
Sponsored Link

Java Answers Forum
urgent - conversion problem

2 replies on 1 page. Most recent reply: Apr 20, 2004 4:24 PM by Matt Gerrans

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Courtenay

Posts: 23
Nickname: courtz
Registered: Apr, 2003

urgent - conversion problem Posted: Apr 18, 2004 1:27 AM
Reply to this message Reply
Advertisement
I have managed to convert an int to a byte[], but now I need to be able to convert that byte[] into a float. I have converted a float into a byte [] using floatToIntBits method and an intToBytes method. How do I reverse that?


mausam

Posts: 243
Nickname: mausam
Registered: Sep, 2003

Re: urgent - conversion problem Posted: Apr 18, 2004 10:03 PM
Reply to this message Reply
I would have done it into this way.

//First convert the byte array to string.
String stringForFloat = new String[byteArr];
 
//Convert this String to float.
 
float f = Float.parseFloat(stringForFloat);

Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: urgent - conversion problem Posted: Apr 20, 2004 4:24 PM
Reply to this message Reply
Maybe I don't understand exactly what you are saying, but if what you did is convert an int to a byte array and now you want that value as a float, why not convert it back to an int and cast that int to a float?

Flat View: This topic has 2 replies on 1 page
Topic: Java Sales Tax Grand Total Previous Topic   Next Topic Topic: cannot retrieve some methods from xerces.jar

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use