*
The moose likes Beginning Java and the fly likes convert array of float to array of string Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "convert array of float to array of string" Watch "convert array of float to array of string" New topic
Author

convert array of float to array of string

sina milka
Greenhorn

Joined: Jan 30, 2004
Posts: 7
hi all,
i have an array of float and i want to get the float values in term of string s (i.e.,converting my float array into string array)as i have to later use the string values to concate with few coeffs like x1,x2,x3..... and write a final formula to output file like
total= (x1)(1.9312)+(x2)(1.5874)+......... where 1.9312 and 1.5874 are my float values in the float array which i wanna convert to string .help me out.
thanx alot in advance
jason adam
Chicken Farmer ()
Ranch Hand

Joined: May 08, 2001
Posts: 1932
Moving this to the Beginners forum
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
I'm not certain I've understood what you're trying to accomplish.
It seems to me that you don't need to create an array of Strings from your array of floats, as you mentioned these values would simply be concatenated to other Strings later on. Well, you could simply just "add" the float values to these other String values with the + operator, much like concatenating Strings the ol' fashioned way.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Wayne L Johnson
Ranch Hand

Joined: Sep 03, 2003
Posts: 399
Try:

If you want to control how they values are formatted, such as how many digits you want after the decimal point, look at the "java.text.DecimalFormat" class. If you don't do this, a value such as 2.00f might appear as 1.99999999999 because of how Java treats real numbers.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: convert array of float to array of string
 
Similar Threads
What makes a language good or better?
nested logic:iterate
Using == with Strings
String Memory Question
About Strings...