convert string (an equation) to float
in
Programming Questions
•
1 year ago
here I got a question in processing.org,
if I wrote:
float result= 1+3*5;
println(result);
I will get 16;
but the input here I have is the string="1+3*5";
float result = string;
it will occour an error,
I tried the following:
anyone knows how to solve that?
Great Thanks,
Leo
if I wrote:
float result= 1+3*5;
println(result);
I will get 16;
but the input here I have is the string="1+3*5";
float result = string;
it will occour an error,
I tried the following:
float f = Float.valueOf(str).floatValue();but they don't work.
or
float f = new Float(str);
anyone knows how to solve that?
Great Thanks,
Leo
1