Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

convert array of float to array of string

 
sina milka
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the Beginners forum
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Wayne L Johnson
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic