• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

convert array of float to array of string

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Chicken Farmer ()
Posts: 1932
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving this to the Beginners forum
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Enjoy the full beauty of the english language. Embedded in this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic