FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Syntax
(Moderators: fry, REAS)
   *vanished* question on parsing ints and floats
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: *vanished* question on parsing ints and floats  (Read 276 times)
Martin

122417302122417302martingomez_listsmg1ph WWW Email
*vanished* question on parsing ints and floats
« on: Mar 14th, 2003, 12:11pm »

hmm... the topic suddenly vanished. anyway, here's the answer
 
Code:
float f;
int i = 0;
String s = "hello 1 2 3 4 5 5.5";
String[] ss = s.split(" ");
for(int j = 1; j < ss.length-1; j++)
{  
   i += Integer.parseInt(ss[j]);
   if(j < ss.length-2){
     print(ss[j]+" + ");
   }
   else {
     print(ss[j]);
   }
}
println(" = "+i+"// Integers");
f = i + Float.parseFloat(ss[ss.length-1]);
println(f+"// Integer sum plus 5.5 (Float)");
 
Pages: 1 

« Previous topic | Next topic »